When you’ve downloaded a disk image for your Raspberry Pi, you need to copy it to your SD card. You can follow the simple instructions, but if you have to do this a lot it’s easier just to have a script that does it for you.
I wrote this script for use on my MacBook Air. It takes the disk image file as a parameter, e.g.
./copytocard debian6-19-04-2012.img
NOTE: The disk devices could be different on your computer. This script could wipe out the wrong disk if the wrong device numbers are used. I’m providing the script for convenience; please ensure you check it carefully before using it on your own computer. Take a look at the simple instructions so you can check which device numbers you need.
#!/bin/bash [[ $# -eq 0 ]] && echo "I need an image file" && exit 1 IMG=$1 echo -n "Waiting for card" df -h | grep disk2s1 RES=$? while [[ $RES -gt 0 ]] ; do echo -n . sleep 1 df -h | grep disk2s1 > /dev/null RES=$? done echo echo "Disk found" echo "Unmounting..." diskutil unmount /dev/disk2s1 echo "Copying (please wait)..." dd bs=1m if=$1 of=/dev/rdisk2 echo "Ejecting..." diskutil eject /dev/rdisk2 echo "Done. Remove card."
That look pretty easy. Could you change the script around a little to make a backup of the SD card as well?
You mean a backup of a card that you’ve already been working on, so you can preserve its state for reuse later? Yes, I’m sure that could be done fairly easily. I think you’d just need to run the dd command with the “if” and “of” arguments swapped, so “if” is the SD card, and “of” is an img file on the Mac. I’d have to try it first to be sure though!