Appendix A. Writing an SD Card Image

While this book has focused on the Raspbian operating system, there are many other distributions that can run on the Raspberry Pi. With any of them, you need to simply download the disk image and then not-so-simply copy the disk image onto the SD card. Here’s how to create an SD card from a disk image on OS X, Windows, and Linux.

Writing an SD Card from OS X

  1. Open your Terminal utility (it’s in /Applications/Utilities) to get a command-line prompt.

  2. Without the card in your computer’s SD card reader, type df -h. The df program shows your free space, but it also shows which disk volumes are mounted.

  3. Now insert the SD card and run df -h again.

  4. Look at the list of mounted volumes and determine which one is the SD card by comparing it to the previous output. For example, an SD card mounts on our computer as /Volumes/Untitled, and the device name is /dev/disk3s1. Depending on the configuration of your computer, this name may vary. Names are assigned as devices are mounted, so you may see a higher number if you have other devices or disk images mounted in the Finder. Write the card’s device name down.

  5. To write to the card, you’ll have to unmount it first. Unmount it by typing sudo diskutil unmount /dev/disk3s1 (using the device name you got from the previous step instead of /dev/disk3s1). Note that you must use the command line or Disk Utility to unmount. If you just eject it from the Finder, you’ll have to take it out and reinsert it (and you’ll still need to unmount it from the command line or Disk Utility). If the card fails to unmount, make sure to close any Finder windows that might be open on the card.

  6. Next, you’ll need to figure out the raw device name of the card. Take your device name and replace disk with rdisk, and leave off the s1 (which is the partition number). For example, the raw device name for the device /dev/disk3s1 is /dev/rdisk3.

Warning

It is really important that you get the raw device name correct! You can overwrite your hard drive and lose data if you start writing to your hard drive instead of the SD card. Use df again to double-check before you continue.

  1. Make sure that the downloaded image is unzipped and sitting in your home directory. You’ll be using the Unix utility dd to copy the image bit by bit to the SD card. The following code snippet is the command; just replace the name of the disk image with the one you downloaded, and replace /dev/rdisk3 with the raw device name of the SD card from step 6.

    You can learn more about the command line in Chapter 3, but you’re essentially telling dd to run as root and copy the input file (if) to the output file (of):

    sudo dd bs=1m if=~/2012-09-18-wheezy-raspbian.img of=/dev/
      rdisk3
    
  1. It will take a few minutes to copy the whole disk image. Unfortunately, dd does not provide any visual feedback, so you’ll just have to wait. When it’s done, it will show you some statistics; eject the SD card and you’re ready to try it on the Pi.

Writing an SD Card from Windows

  1. Download the Win32DiskImager program.

  2. Insert the SD card in your reader and note the drive letter that pops up in Windows Explorer.

  3. Open Win32DiskImager and select the Raspbian disk image.

  4. Select the SD card’s drive letter, then click Write. If Win32DiskImager has problems writing to the card, try reformatting it in Windows Explorer.

  5. Eject the SD card and put it in your Raspberry Pi; you’re good to go!

Writing an SD Card from Linux

The instructions for Linux are similar to those for the Mac:

  1. Open a new shell and without the card in the reader, type df -h to see which disk volumes are mounted.

  2. Now insert the SD card and run df -h again.

  3. Look at the list of mounted volumes and determine which one is the SD card by comparing it to the previous output. Find the device name, which should be something like /dev/sdd1. Depending on the configuration of your computer, this name may vary. Write the card’s device name down.

  4. To write to the card, you’ll have to unmount it first. Unmount it by typing umount /dev/sdd1 (using the device name you got from the previous step instead of /dev/sdd1). If the card fails to unmount, make sure it is not the working directory in any open shells.

  5. Next, you’ll need to figure out the raw device name of the card, which is the device name without the partition number. For example, if your device name was /dev/sdd1, the raw device name is /dev/sdd.

Warning

It is really important that you get the raw device name correct! You can overwrite your hard drive and lose data if you start writing to your hard drive instead of the SD card. Use df again to double-check before you continue.

  1. Make sure that the downloaded image is unzipped and sitting in your home directory. You’ll be using the Unix utility dd to copy the image bit by bit to the SD card. Here is the command—just replace the name of the disk image with the one you downloaded, and replace /dev/sdd with the raw device name of the SD card from step 5:

    sudo dd bs=1M if=~/2012-09-18-wheezy-raspbian.img of=/dev/
      sdd
    

    This command tells dd to run as root and copy the input file (if) to the output file (of).

  1. It will take a few minutes to copy the whole disk image. Unfortunately, dd does not provide any visual feedback, so you’ll just have to wait.

    When it’s done, it will show you some statistics. It should be OK to eject the disk, but just to make sure it is safe, run sudo sync, which will flush the filesystem write buffers.

  2. Eject the card and insert it in your Raspberry Pi. Good to go!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset