Tuesday 26 February 2013

Raspberry Pi SD Card Setup Using a Mac

There are a lot of instructions available on how to set up a Raspberry Pi SD Card using a Windows PC. I thought I would share my method of doing this on an Apple Mac.

First download the image you would like to burn onto the SD Card. Generally I use Raspbian, and think this is a good place to start. The latest image can be found from here.

http://www.raspberrypi.org/downloads

The file is fairly large so can take several minutes to download, depending on your internet connection, so it is worth starting the download before proceeding.

Now it is important to take a note of the locally mounted disks before inserting the SD Card. To do this you will have to open the Apple Mac Terminal. This is found under Utilities within the Applications folder.



Once in the terminal on the mac type the following:

df -h

This should list all the locally mounted drives.




Now connect the SD Card into a USB port. I have a small USB SD Card reader for this purpose. If you need one these they can be picked up very cheaply from the internet.

Once the card is inserted you need to again type:

df -h




You should now be able to compare the first and second instances of df -h. As you can see I now have an additional drive /dev/disk2s1 connected to my Apple Mac.

It is worth checking that the additional drive looks as expected. I know my SD Card is 8 GB unformatted, and is called UNTITLED, which ties in with the 7.4GB (always less when formatted) stated against /dev/disk2s1. Getting the name wrong could have disastrous consequences. You have been warned...

In the command line now unmount the disk by typing:

diskutil unmount /dev/disk2s1




If your file has finished downloading you will need to unzip it before continuing with the installation.

To do this double click on the .zip file you have downloaded and this should start to unzip.




Again this next part is important so care should be taken.

If your SD Card inserted shows up as /dev/disk2s1 you will have to type rdisk2 in the next stage i.e. you ignore the /dev/ and the s1 part, but add an r in front of disk.

Next you need to know which directory you downloaded and unzipped the file into. Normally this is in your Downloads folder. If you downloaded it elsewhere you should change the path to the file. Ensure you also change the filename to match the file you have downloaded. For a file called 2013-02-09-wheezy-raspbian.img in the Downloads folder I would type:

dd bs=1m if=~/Downloads/2013-02-09-wheezy-raspbian.img of=/dev/rdisk2



If you get a permission denied message use sudo before the command. i.e.

sudo dd bs=1m if=~/Downloads/2013-02-09-wheezy-raspbian.img of=/dev/rdisk2

Then type your Apple Macs password when asked.

This stage takes several minutes, so please be patient.

Finally type:

diskutil eject /dev/rdisk2



again modifying this to match as previously discussed.

Your SD Card is now ready with the latest version of Raspbian installed. Enjoy!