Hardware accessories
Now that you have your Raspberry Pi hardware you will need a Secure Digital flash memory card and a Micro USB power supply.
SD cards are plentiful. Purchase one of 4GB or more. Class 10 cards are fastest, but not all of these boot on the Raspberry Pi without firmware updates. Class 6 cards are cheaper but slower. Don't bother cards slower than Class 6, they really aren't that much cheaper and the resulting performance of the Raspberry Pi is dreadful. The larger supermarkets and office supply stores have good prices. For example, Officeworks has a "SanDisk Extreme HD Video SD HC Card 4GB", which is a Class 6 card, for A$17; the 8GB card is good value $25 and capacities above that currently have a rapidly rising cost per GB.
If your computer doesn't have a SD card slot then this would also be a good time to buy a USB/SD card dongle. Expect to pay about A$11 at Officeworks.
Plug packs with Micro USB connectors are easily found. In a retail setting, such as a mobile phone shop, you are looking at around A$30; in an electronics store like Jaycar or Altronics you are looking at around $20. If you do buy one from a retail store then check the output current: I have seen $30 plugpacks ranging from 650mA to 1200mA. Buy the highest output current you can, anything under 800mA is best avoided as the voltage sag under load will cause the Raspberry Pi to show faults.
You can also assemble a micro USB power source from a 240VAC to USB power source (A$15, or less if you keep your eyes open) and a USB-micro USB adapter (A$11 from Officeworks). The iPad and iPhone charger outputs 1000mA and the iPad2 charger outputs 2000mA.
The USB ports on the Raspberry Pi are very low powered, just enough to drive a keyboard and mouse. If you want to do something more than this then use a powered USB hub. There are substantial compatibility issues with these, as some feed voltage back to the host USB port, and the Raspberry Pi does not like that. The website www.elinux.org has a list of hubs which people have successfully used. Powered USB hubs are not popular, and so are around $30 for a 4 port hub (compared with $4 for a non-powered hub). Definately worth while shopping about.
The Raspberry Pi also has a history of packet drops on its USB port when connected to a powered hub. This seems to get better with each firmware revision. This is a major bug, since connecting a hard disk through a powered USB hub to the Raspberry Pi is just asking for data corruption.
If you are shopping for a hard disk then buy the larger USB drives which come with their own power supply rather than taking current from the host. These can be plugged directly into the Pi without a powered hub.
You'll also want to communicate with the Raspberry Pi. If you want graphics then find a USB keyboard, USB mouse and a HDMI cable. You should be able to pick up the keyboard and mouse for free on any kerbside collection day. HDMI cables are best bought from Jaycar or Altronics or Officeworks or anywhere else that isn't charging more than $10.
If you want to run headless you can connect to the ethernet ports on your ADSL router or office switch, for that you'll want a Category 5 or better UTP patch lead. These are around $5 from Rexel or $10 from Officeworks or electronics stores.
All these little items can add up, and if your Raspberry Pi seller has an optional "parts pack" then you may be able to save quite a bit. Farnell were intending to do this, but the demand for the Raspberry Pi hammered them so much that they haven't had the chance to do so yet.
Choosing a Linux distribution
There are quite a few SD card images available for the Raspberry Pi. Unfortunately the Raspberry Pi is often the victim of compatibility choices made by the distribution. The Raspberry Pi CPU is an ARM CPU with the ARMv6 instruction set with the optional vector floating point unit. Debian supports the ARMv6 with software-emulated floating point and the ARMv7 (where floating point was always included, not optional).
Ubuntu is not available as it requires ARMv7 as a minimum.
Fedora is compiled for ARMv6 with software-emulated floating point. It has a Remix aimed at the Raspberry Pi, but this is focussing on the user experience, such as allowing the partition on the SD card to be resized during the first boot.
The Raspbian distribution is Debian recompiled for exactly (and thus pretty much only) the ARM CPU used in the Raspberry Pi. The performance improvement over the stock Debian is considerable. This makes Raspbian the distribution of choice at the time of writing. Raspbian is likely to remain the best choice for headless use; hopefully a Pi-tuned Fedora or Ubuntu will eventually appear.
Writing the distribution to the CD card from a Linux machine
Download the image file for the distribution. I'll use Raspbian in the examples.
$ wget http://mirror.aarnet.edu.au/pub/raspberrypi/images/raspbian/2012-07-15-wheezy-raspbian/2012-07-15-wheezy-raspbian.zip $ unzip -l 2012-07-15-wheezy-raspbian.zip Archive: 2012-07-15-wheezy-raspbian.zip Length Date Time Name --------- ---------- ----- ---- 1939865600 2012-07-16 05:15 2012-07-15-wheezy-raspbian.img
Insert the SD card into the computer. Formatted partitions on that card usually automatically mount. Type mount and note the disk name; for example, /dev/sdb is the disk containing the mounted partition /dev/sdb1. Unmount the automatically mounted partitions with udisks --unmount /media/*. Type mount again and ensure that the disk you expected to unmount was the disk which was unmounted. Any confusion about which disk is the SD flash card will cause major problems in a moment.
Write the downloaded image to the SD card. We could do this by unpacking the .zip file and then writing the expanded image, but this is UNIX and not a toy operating system, so we can do without the time-consuming intermediate step:
$ unzip -p 2012-07-15-wheezy-raspbian.zip 2012-07-15-wheezy-raspbian.img | sudo dd of=/dev/sdb bs=64k 29600+0 records in 29600+0 records out 1939865600 bytes (1.9 GB) copied, 163.944 s, 11.8 MB/s
You can have a knowingly cynical laugh when comparing the I/O rate reported by dd (11.8MBps) versus the rate printed on the SD card's promotional packaging (30MBps).
Eject the SD card and put it into the Raspberry Pi. It will only go one way.
Thunderbirds are go!
Plug in the micro USB power supply, watch the LEDs on the board light up. If you are directly connected you'll see the Raspberry Pi logo on the screen.
If you are headless then you'll need to determine the IP address or DNS name to use.
-
A few networks use Dynamic DNS, in this case the DNS name will be "raspberrypi".
-
If you connected to a ADSL router, use the router's administration screens to determine the IPv4 address which was allocated.
-
If you are connected to a larger network, then ask the network adminstrator to tell you the allocated IPv4 address. They'll look at the /var/log/messages or /var/lib/dhcpd/dhcpd.leases of the DHCP server.
Log in as the user "pi" with the password "raspberry". If you are headless say ssh pi@raspberrypi or ssh pi@203.0.113.1 or whatever address you were assigned.
Localise the installation
Start the handy configuration tool. This is a menu front end to some commands and saves a lot of typing.
$ sudo raspi-config
Choose the "expand_rootfs" option to expand the installed partition to the full size of the SD card. It will ask you to reboot, do that with sudo shutdown -r now.
Reconnect and run raspi-config again. I set these values:
-
configure_keyboard to "PC-104" "US". If this doesn't have the desired effect then alter /etc/defaults/keyboard so that XKBLAYOUT="us", then run sudo setupcon.
-
change_locale to "en_AU.UTF-8 UTF-8". The command-line equivalent is sudo dpkg-reconfigure locales.
-
change_timezone to "Australia/Adelaide". The command-line equivalent is sudo dpkg-reconfigure tzdata.
-
Since I am running headless, memory_split to "224 224MiB for ARM, 32MiB for VideoCore"
Reboot again.
Update the installed software
I am in Australia, so the AARNet mirror is the best location for Raspbian updates. I altered /etc/apt/sources.list from
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
to
deb http://mirror.aarnet.edu.au/pub/raspbian/raspbian/ wheezy main contrib non-free rpi
and then updated the installed software with:
$ sudo apt-get update $ sudo apt-get --auto-remove --purge dist-upgrade $ sudo apt-get clean
The Raspberry Pi also has firmware. This simplest way to update this is through rpi-update:
$ sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update $ sudo chmod +x /usr/bin/rpi-update $ sudo apt-get install git-core $ sudo rpi-update $ sudo shutdown -r now
Secure the Pi
Now is a good moment to change the name of the Raspberry Pi from "raspberrypi" if you wish. I used the shorter "rpi":
$ echo "rpi" | sudo tee /etc/hostname $ sudo vi /etc/hosts :1,$s/raspberrypi/rpi/g :wq $ sudo /etc/init.d/hostname.sh restart
Being an image, everyone's SSH host keys are the same. That's not good. Regenerate the keys with:
$ sudo rm /etc/ssh/ssh_host_* $ sudo dpkg-reconfigure openssh-server Creating SSH2 RSA key; this may take some time ... Creating SSH2 DSA key; this may take some time ... Creating SSH2 ECDSA key; this may take some time ... Restarting OpenBSD Secure Shell server: sshd. [ ok ]
Being an image, everyone's passwords are the same.That's not good. Set a password for the "root" superuser with:
$ sudo passwd root
Rather than change the password of the "pi" user, create a user for yourself (in our example, "fredbloggs") with:
$ sudo useradd -c 'Fred Bloggs' -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input fredbloggs $ sudo passwd fredbloggs
It is best if the username is in lower case and doesn't contain spaces or other punctuation.
Log out of the "pi" account and test that your new account can log in and can run the sudo command.
In UNIX we don't delete accounts, we lock them:
$ sudo usermod -e 1 -L pi
You probably don't want to SSH to the Rasberry Pi as the root user, so stop people even trying (bad people will send entire dictionaries to try to log in as the root user in an attack called "door knocking"). Alter the "PermitRootLogin" line in /etc/ssh/sshd_config to "PermitRootLogin no" and restart the SSH server with sudo /etc/init.d/sshd restart.
So long and thanks for all the fish
Your Raspberry Pi is now fully installed and ready to go. There is a lot more you could do with it, but that's beyond the scope of this note. It's already long enough as it is (but hey, if you want short content-less puff pieces which make you wonder if everyone on the whole #!*$%@# planet hasn't started their own personal PR agency, then that's what Facebook or Twitter are for).
Other tasks
Consider the following:
Enable IPv6
Install random number daemon
Put swap into a 1GB partition if using a 16GB card (makes startup faster)
Move the indiecity, spi, and gpio groups out of the user groups range
Truncate log files
Change apt-get sources