This week I got a RaspberryPi to play around with at home. I found instructions to put the Raspbian image file onto the SD card that I bought using a article over at PenguinTutor.com. Got me up and going quick with a basic linux installation. I still have to go through and set up a firewall, but will do that later this week since this isn’t internet facing atm.
So with the basics installed, I wanted to backup the SD card in case it fails, having to re-install everything is not what I want to do if I don’t have too. Therefore I wanted to back up the SD card. The first thing you want to do is identify the unix device path of the SD card.
Open the Terminal Application. You can use finder’s search functionality to find it if you don’t know where it is. Or navigate into Applications -> Utilities -> Terminal
Use the command “df -h” to get a list of volumes.
Filesystem Size Used Avail Capacity Mounted on
/dev/disk0s2 465Gi 406Gi 59Gi 88% /
devfs 187Ki 187Ki 0Bi 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% /net
map auto_home 0Bi 0Bi 0Bi 100% /home
/dev/disk1s1 56Mi 17Mi 39Mi 30% /Volumes/RASPBIAN
In my case my SD card is named RASPBIAN. The device path in my case is /dev/disk1s1 for the SD card. Next we want to unmount the SD card, but not eject the card. This is done from the “Disk Utility” application which is also located in the Utilities folder “Application -> Utilities -> Disk Utility”. You will see the SD card in the list. Select the volume and click the “Unmount” button on the top. This will unmount the drive from finder, but still allow us to make an image of it.
Next we are going to use the unix “dd” command. This command is very dangerous if you don’t use it correctly. This could totally destroy your hard disk if you mess up so be VERY careful. dd stands for “Destroy Disk”
sudo dd if=/dev/disk1s1 of=/Users/username/backup.img
The "if" argument is input file. the "of" argument is output file. In this case is the input file is the device path to our SD card. The output file is the path to save the image file too. Once the command finishes you should have a backup image if your Rasbian installation.