Raspberry Pi Setup
Yesterday I got my Raspberry Pi and this post serves as reference for myself for whenever I need to setup a new SD card for it.
Creating SD card for Raspberry Pi
Download latest image from http://www.raspberrypi.org/downloads. In my case I have chosen Raspbian “wheezy”
Checksum validation
Check to see if the download package has not been tampered with
Thoth:Raspberry Pi fmeus$ shasum 2013-05-25-wheezy-raspbian.zip
131f2810b1871a032dd6d1482dfba10964b43bd2 2013-05-25-wheezy-raspbian.zip
Which matches the information presented on the Downloads page at http://www.raspberrypi.org/downloads
Determine device for SD card
df -h
Before inserting the SD card
Thoth:Raspberry Pi fmeus$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 734Gi 573Gi 160Gi 79% 150402219 41885801 78% /
devfs 189Ki 189Ki 0Bi 100% 654 0 100% /dev
/dev/disk1s2 931Gi 549Gi 382Gi 59% 144002013 100104652 59% /Volumes/Iomega 1TB HDD
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk0s4 197Gi 26Gi 171Gi 14% 92997 179040039 0% /Volumes/BOOTCAMP
After inserting the SD card
Thoth:Raspberry Pi fmeus$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 734Gi 573Gi 160Gi 79% 150402219 41885801 78% /
devfs 189Ki 189Ki 0Bi 100% 654 0 100% /dev
/dev/disk1s2 931Gi 549Gi 382Gi 59% 144002013 100104652 59% /Volumes/Iomega 1TB HDD
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk0s4 197Gi 26Gi 171Gi 14% 92997 179040039 0% /Volumes/BOOTCAMP
/dev/disk2s1 7.4Gi 2.1Mi 7.4Gi 1% 0 0 100% /Volumes/NO NAME
My fresh out of the box 8GB SD card
/dev/disk2s1 7.4Gi 2.1Mi 7.4Gi 1% 0 0 100% /Volumes/NO NAME
For the next steps we will be using the device as a RAW device, so we drop s1
from its name and put an r
in front of it, so we get /dev/rdisk2
Unmount SD card volume
Thoth:Raspberry Pi fmeus$ diskutil unmount /dev/disk2s1
Volume NO NAME on disk2s1 unmounted
Copy Debian image to SD card
Raw device name : /dev/rdisk2
Sections from the manpage for dd
bs=n - Set both input and output block size to n bytes, superseding the ibs and obs operands. If no conversion values other than noerror, notrunc or sync are specified, then each input block is copied to the output as a single block without any aggregation of short blocks.
if=file - Read input from file instead of the standard input.
of=file - Write output to file instead of the standard output. Any regular output file is truncated unless the notrunc conversion value is specified. If an initial portion of the output file is seeked past (see the oseek operand), the output file is truncated at that point.
Thoth:Raspberry Pi fmeus$ sudo dd if=2013-05-25-wheezy-raspbian.img of=/dev/rdisk2 bs=1m
Password:
1850+0 records in
1850+0 records out
1939865600 bytes transferred in 167.931297 secs (11551543 bytes/sec)
There is now a 2GB boot partition and 6GB of unallocated (wasted) space on the SD Card. Next step is reclaiming that unallocated disk space.
Expanding the filesystem
For this step we need to boot the Raspberry Pi. You will either on start-up be presented with the configuration tool. If this is not the case issue the following command from the terminal window to start the configuration tool
sudo raspi-config
Run the first option in the menu ‘Expand Filesystem’ (Using 2013-05-25-wheezy-raspbian), the the apt description ‘Ensures that all of the SD card storage us available to the OS’.
The next time you boot your Raspberry Pi it will have access to the complete SD card
Installing some additional software
Install Chromium browser
sudo apt-get install chromium-browser
Might be a good idea to disable the Flash plug-in (if installed, wasn’t the case in my installation)
enter chrome://plugins in the omnibox (search bar) and disable the flash plugin
Install vncserver
To install Tight VNC server, issue the following command
sudo apt-get install tightvncserver
Next issue the following command to start the VNC server
vncserver :0 -geometry 1280x800 -depth 24
To have the VNC server start-up automatically follow the instructions posted here. I followed these instructions, with two exceptions I used :0 instead of :1 (this was it was easier to access the Pi from my Mac) and instead of
su root -c 'vncserver :1 -geometry 1280x800 -depth 24'
I used the following. This way when connecting to the desktop it will run under the use pi instead of the root user
vncserver :0 -geometry 1280x800 -depth 24
Access your Raspberry Pi by hostname
By default to ssh into the raspberry pi you need to use its IP address. If you are using DHCP you would have to lookup its IP address every time. By installing Avahi you will be able to connect to your Raspberry Pi using its assigned hostname
sudo apt-get install avahi-daemon
Creating backup
Very similar to the process for creating the bootable SD card.
sudo dd if=/dev/rdisk2 of=/Users/fmeus/2013-05-25-wheezy-raspbian-modified.img bs=1m
NOTE: If the backup is created after running ‘Expand filesystem’, you can only restore backup image to a SD card of similar size or larger. In my case the backup image was 7948206080 bytes large (approx. 8GB)
Useful commands
Shutting down
sudo halt
or
sudo shutdown -h now
Rebooting
sudo reboot
or
sudo shutdown -r now
Updating installed packages
Synchronize the packages index files from their sources
sudo apt-get update
Install the latest versions of all packages installed on the system
sudo apt-get upgrade