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.
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ â Raspi-config â â â â info Information about this tool â â expand_rootfs Expand root partition to fill SD card â â overscan Change overscan â â configure_keyboard Set keyboard layout â â change_pass Change password for 'pi' user â â change_locale Set locale â â change_timezone Set timezone â â memory_split Change memory split â â ssh Enable or disable ssh server â â overclock Configure overclocking â â boot_behaviour Start desktop on boot? â â update Try to upgrade raspi-config â â â â â â â â <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.
- First, choose “update” to update the configuration program to the latest version. It drops you back on the command line, so start the configure program up again with another sudo raspi-config once the update process is complete. Handy hint: use the up and down arrows on the keyboard to scroll through previous commands.
- If your SD card is larger than 2GB then “expand_rootfs” will allow you to use all the card’s memory rather than just 2GB of it.
- 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. Previous “raspi-config”s had a list of choices, where you should pick the top option “224MiB for ARM, 32MiB for VideoCore”. The latest version allows you to 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.
- change_timezone: Use this to set the timezone to where you are.
- overclock: This is a new one, appearing in the latest release of Raspbian. If you do not have this option, do an apt-get dist-upgrade (upgrading is covered here) to upgrade raspi-config. 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.
- ssh: Make sure that this is set to “Enable”. Otherwise you won’t be able to log in again.
Don’t bother changing the password for “Pi”, we are going to create a new user for you to log in with and then delete Pi. Apart from it being nice to have your own login, it’s a bit of a security risk to leave a default user and bloody lethal to leave a default password on a system.
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.