Your Pi is now sitting in the corner of the room, blinking its lights at you and presumably working. Shall we see if we can do something with it?
3. Setting up the interweb
Your Pi is working and sitting on the network, waiting for you. But where is it? You need to know its address on your network in order to log in, but it will have booted using DHCP, so its address is known only to the Pi and the router. You need to set up your Pi with a permanent, static IP address of your choosing, as well as a gateway address (the address of the router on the LAN side) and subnet mask. If you are a bit unsure how to select these, Appendix A might help.
We need to edit a configuration file on the SD card in order to change the settings. Put your SD card back into your card reader. What you do next depends on what sort of computer you are using.
If you use Linux on your PC then it’s easy enough – go into the “/etc/network” directory in the larger partition and edit a file called “interfaces”, as shown below, with a text editor like gedit. Do not use a word processor such as OpenOffice or LibreOffice.
The /etc/network/interfaces file looks like this:
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. auto lo iface lo inet loopback iface eth0 inet dhcp
Leave the lines up to “iface eth0…” alone, change that line and add 3 new ones like this:
iface eth0 inet static address 192.168.1.5 gateway 192.168.1.254 netmask 255.255.255.0
With “address” being the IP address you want to assign your Pi, “gateway” your gateway and the “netmask” for your home network. Once you have changed the text and saved the file over the top of the original, safely remove the card, put it in your Pi and reboot.
Unfortunately it’s not that easy for Windows users. Windows can’t read the Ext3 partition the “interfaces” config file resides in. This means we have to temporarily force the Pi to use a static IP and then edit the config file on the Pi itself. Look in the list of files on the card (the 59MB partition) for a file called “cmdline.txt” Open it up with a text editor – Wordpad is best, do NOT use Word or any sort of word processor. You will see this:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Make sure that line wrapping is turned off (View->Word wrap->No wrap for Wordpad) and add the text in bold at the end of the line after “rootwait” (with a space between “rootwait” and “ip=192…”:
... rootwait ip=192.168.1.5::192.168.1.254:255.255.255.0::eth0:none
That’s your desired IP for your Pi, two colons, the gateway address, one colon, the netmask, two colons, “eth0″, colon, “none”. Make sure that the text is all on one line with a newline at the end, and save the file over the original. Safely remove the card, put it in your Pi and start it up. Keep following the tutorial for now. We’ll sort your Pi out permanently once you’ve logged on and used the text editor a bit.
4. Logging in
Like any sane computer, the Pi uses SSH to provide an external terminal (or “shell”) in which to do your work. It is secure because it is encrypted from log in onwards – no one can sniff your password, username or anything you type during your session. If you use Linux on your home PC then you’ve already got a SSH client, but if you are unlucky enough to be using Windows, you’ll need to download PuTTY from here. Start PuTTY up and enter the IP address you picked where it says “Host name (or IP address)” and click “Open”. Linux users, start a shell and type ssh -l pi 192.168.1.5 (replace the 192… with your Pi’s IP address). The username is “pi” and the password for it is “raspberry”. You should see this:
Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Type 'startx' to launch a graphical session NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config' pi@raspberrypi:~$
Hooray! You are logged in and the world is your lobster. From now on we’ll be typing commands to do things. Whenever you see the line that says “pi@raspberrypi:~$” (or a variant of it), it means the Pi is waiting for you to type something in.
5. Initial configuring
You see that bit where it says “NOTICE: the software on this Raspberry Pi has not been fully configured. Please run ‘sudo raspi-config’”? That’s sound advice. Type sudo raspi-config or copy and paste the words from the login text.
âââââââââââ¤ Raspberry Pi Software Configuration Tool (raspi-config) ââââââââââââ Setup Options â â â â 1 Expand Filesystem Ensures that all of the SD card s â â 2 Change User Password Change password for the default u â â 3 Enable Boot to Desktop Choose whether to boot into a des â â 4 Internationalisation Options Set up language and regional sett â â 5 Enable Camera Enable this Pi to work with the R â â 6 Add to Rastrack Add this Pi to the online Raspber â â 7 Overclock Configure overclocking for your P â â 8 Advanced Options Configure advanced settings â â 9 About raspi-config Information about this configurat â â â â â â <Select> <Finish> â â â ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
You will see a menu pop up with loads of options. Move the highlighted line with the up/down arrow keys and hit return to select an option. The options in “<>”s are selectable with the tab button, so tabbing twice would take you to the “Finish” option, where you hit return to do it.
- If your SD card is larger than 2GB then choose option 1 – “Expand Filesystem”. This will allow you to use all the card’s memory rather than just 2GB of it.
- Don’t bother with 2 – “Change user password”. We’ll be getting rid of the user in a minute anyway.
- Don’t do 3 – “Boot to desktop” either. We are being macho and using the command line only.
- Select 4 – “Internationalisation Options” to go to the options page to set the timezone and “locale” (which sets various preferences like number format, date-time format) to your country. “Timezone” is fairly straightforward, but “locale” is less so. It offers you a list of baffling lines of text, which is comprised of language_territory.codeset with abbreviations for “language” and “territory”. If you are in the UK then “en_GB.UTF-8 UTF-8″ is the one you want. When you find the one you want, hit the space bar to star it and then tab a couple of times to the “OK” button.
- 7 – Overclock: This setting allows you to speed up your pi by tweaking the clock speed and voltage of the CPU. Higher values mean your Pi runs faster, but too high a value could make it unstable. Experiment a bit with it and if you find you have problems, lower the settings until it’s happy.
There are a couple of things in 8 – “Advanced options” that we need to do, so select it and choose:
- A3 – “Memory Split”: RAM on the Pi is split between the CPU and graphics chip (GPU). As it’s not plugged into the TV you don’t need graphics. Choose this option and enter a number for how much memory the GPU should have. The number to use is 16, which is the minimum memory you can assign for the GPU.
- A4 – “SSH”: Make sure that this is set to “Enable”. Otherwise you won’t be able to log in again.
Once you’ve finished with the config program, press Tab twice to highlight “Finish” and hit return. You can reboot your Pi when prompted or drop back to the command line (“pi@raspberrypi ~ $”) and type sudo reboot to do it manually. Leave it for a couple of minutes and then log in again (pi/raspberry). As a quick check to see if your Pi is now using the whole SD card, type df -h
naich@raspberrypi ~ $ df -h Filesystem Size Used Avail Use% Mounted on rootfs 3.6G 3.4G 72M 98% / /dev/root 3.6G 3.4G 72M 98% / tmpfs 22M 208K 22M 1% /run tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 44M 0 44M 0% /tmp tmpfs 10M 0 10M 0% /dev tmpfs 44M 0 44M 0% /run/shm /dev/mmcblk0p1 56M 34M 23M 61% /boot naich@raspberrypi ~ $
Look at the line that starts “rootfs”. The “Size” column should report something close to the size of your card – in this case it’s a 4GB card. If it still says it’s under 2GB then the resizing didn’t work. You could try resizing it with the configuration program again (sudo raspi-config) or use this tutorial.
If you are familiar with Linux on the command line you can stop reading my wibblings now. You have, for all intents and purposes, installed Debian Wheezy on your Pi. Go forth and do with it what you will. The rest of you can read on while we do some basic maintenance and then add some USB storage, install a Bittorrent client to download your perfectly legal torrents and a uPNP Media Server to watch them on your TV, PS3 or whatever.