Sunday 22 September 2013

Cloning a Raspberry Pi SD card on a Mac

This really is actually quite simple;

1. Enter source SD card into Mac (make sure you have set it to locked before hand)
2. At the terminal type "df -h", the output will list the inserted disk as something like;

/dev/disk1s1    69Mi  9.1Mi   60Mi    14%        0        0  100%   /Volumes/Untitled
3. Now take a backup of the disk by typing the following;
sudo dd if=/dev/rdisk1 of=/Users/kevingordon/Dropbox/kevscode/RPi-backup/raspbmc-backup.img

Where rdisk1 - the 1 is from the /dev/disk1s1 above. And the of will be the path with the image filename on your hard drive where you want to put the disk image.

4. It will ask your password, and then will take 1/2 hour or so to process. Note you can monitor the activity by opening System monitor and searching for the "dd" process - you will see that it is active. Once it is finished it will return some information like the following;

7744512+0 records in
7744512+0 records out
3965190144 bytes transferred in 4078.160970 secs (972299 bytes/sec)

5. Now eject the disk as normal.
6. Now copy this to the new disk, make sure the disk is unlocked, and enter the SD card
7. In disk utility, unmount the disk, an it should be replaced with something like disk1s1, and disappear from your desktop.
8. At the terminal type the following; 

sudo dd if=/Users/kevingordon/Dropbox/kevscode/RPi-backup/raspbmc-backup.img of=/dev/rdisk1 bs=1m

This may or may not ask for your password. Note the if directory is the location where you put the image file above. Then the of will be the same as the if that you used previously - confirm this information using df -h again.
9. Once the command above is running, it will take 1/2 hour or so, and you can monitor using the System Monitor and searching for the dd process.
10. Once complete it will give you the following (something like);

3781+1 records in
3781+1 records out
3965190144 bytes transferred in 792.939957 secs (5000618 bytes/sec)

11. Eject the disk using disk utility.
12. That's it! - You can now use this in your Raspberry Pi - a fresh clone of whatever you were running previously, awesome!

No comments:

Post a Comment