Writing Raspbian OS to the SD card
Computers can't do anything useful without an operating system, and the Pi is no exception. There is a growing collection of operating systems available for the Pi, but we'll stick with the "officially recommended" OS—the Raspbian GNU/Linux distribution.
Getting Raspbian
There are two main ways to obtain Raspbian. You can either buy it preinstalled on an SD card from your Raspberry Pi dealer, or download a Raspbian image yourself and write it to an empty SD card on a computer with an SD card slot.
Note
If you do have access to a computer but it lacks an SD card slot, it's a wise choice to invest in an external SD card reader/writer. They don't cost much and chances are you'll want to re-install or try a different operating system on your SD card sooner or later.
To download a Raspbian image, visit the site http://www.raspberrypi.org/downloads. Instead of version numbers, Raspbian uses code names (names of characters from the movie Toy Story) and the latest version at the time of writing is Wheezy. Just click on the link for the ZIP file and wait for your download to start or use the torrent link if you prefer, but we will not cover that in this book.
SD card image writing in Windows
Two things are needed to prepare your SD card—an uncompressed image and an image writer application. Perform the following steps to prepare your SD card:
When your image has finished downloading, you'll need to unzip it, usually by right-clicking on the ZIP file and selecting Extract all or by using an application such as WinZip. Once extracted, you should end up with a disc image file named
YYYY-MM-DD-wheezy-raspbian.img
.It is highly recommended that you disconnect any attached USB storage devices for now to minimize the risk of writing the Raspbian image to the wrong place.
Visit http://sourceforge.net/projects/win32diskimager/ and download the latest version of the Win32DiskImager application (
win32diskimager-v0.7-binary.zip
at the time of writing).Extract that ZIP file too and run the Win32DiskImager application. On Windows 7/8 you might need to run it as an administrator by right-clicking on the application and selecting Run as administrator.
Select the IMG file you extracted earlier and choose the volume letter of your SD card slot from the Device drop-down menu. It is very important to verify that you have the correct volume of your SD card! Finally, click on Write and wait for the process to finish.
SD card image writing in Mac OS X or Linux
Two things are needed to prepare your SD card – an uncompressed image and an image writer script.
When your image has finished downloading, you'll need to unzip it, usually by double-clicking on the ZIP file or by right-clicking and selecting Extract here. Once extracted, you should end up with a disk image file named
YYYY-MM-DD-wheezy-raspbian.img
.It is highly recommended that you disconnect any attached USB storage devices for now, to minimize the risk of writing the Raspbian image to the wrong place.
To help us write the Raspbian image file to the SD card, we will be using a Python script written by Aaron Bockover. Visit http://www.intestinate.com/imagewriter.py to download the script and save it to your
Desktop
folder.Open up a Terminal (located in
/Applications/Utilities
on the Mac).Now we need to start the
imagewriter.py
script and tell it where to find the Raspbian IMG file. Adapt the following command to suite the paths of your files:sudo python ~/Desktop/imagewriter.py ~/Desktop/YYYY-MM-DD-wheezy-raspbian.img
If you don't know the full path to your script or IMG file, you can just drag-and-drop the files on to the Terminal window and the full path will magically appear.
You might be asked to input your user password so that
sudo
is allowed to run. The script will ask which device you'd like to write the image to. It will present a list of all the currently attached storage devices. Identify your SD card slot with the help of the device description, and the size that should match your card. Finally, type the number of your device and press the Enter key.If your SD card is currently mounted, the script will prompt you to unmount it first and you'll get a final warning before the operation starts. Answer y to both questions to continue. The progress meter will tell you when the image has been successfully written to your card. You might notice a new storage volume called Untitled. That's the boot partition of Raspbian. You should right-click on this volume and Eject it to safely remove your SD card.
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.