Backup and Restore micro sd card
Before inserting the SD card into the reader on your Linux PC, run the following command to find out which devices are currently available:
df -h
Which will return something like this:
Filesystem 1K-blocks Used Available Use% Mounted on
`
rootfs 29834204 15679020 12892692 55% /`
/dev/root 29834204 15679020 12892692 55% /
`
devtmpfs 437856 0 437856 0% /dev`
tmpfs 88432 284 88148 1% /run
`
tmpfs 5120 0 5120 0% /run/lock`
tmpfs 176860 0 176860 0% /run/shm
`
/dev/mmcblk0p1 57288 14752 42536 26% /boot`
Insert the SD card into a card reader and use the samedf -h
command to find out what is now available:
Filesystem 1K-blocks Used Available Use% Mounted on
`
rootfs 29834204 15679020 12892692 55% /`
/dev/root 29834204 15679020 12892692 55% /
`
devtmpfs 437856 0 437856 0% /dev`
tmpfs 88432 284 88148 1% /run
`
tmpfs 5120 0 5120 0% /run/lock`
tmpfs 176860 0 176860 0% /run/shm
`
/dev/mmcblk0p1 57288 14752 42536 26% /boot`
/dev/sda5 57288 9920 47368 18% /media/boot
` **
/dev/sda6 6420000 2549088 3526652 42% /media/41cd5baa-7a62-4706-b8e8-02c43ccee8d9`**
The new device that wasn't there last time is your SD card.
The left column gives the device name of your SD card, and will look like '/dev/mmcblk0p1' or '/dev/sdb1'. The last part ('p1' or '1') is the partition number, but you want to use the whole SD card, so you need to remove that part from the name leaving '/dev/mmcblk0' or '/dev/sdb' as the disk you want to read from.
Open a terminal window and use the following to backup your SD card:
sudo dd if=/dev/sdb of=~/SDCardBackup.img
As on the Mac, the dd command does not show any feedback so you just need to wait until the command prompt re-appears.
To restore the image, do exactly the same again to discover which device is your SD card. As with the Mac, you need to unmount it first, but this time you need to use the partition number as well (the 'p1' or '1' after the device name). If there is more than one partition on the device, you will need to repeat the umount command for all partition numbers. For example, if thedf -h
shows that there are two partitions on the SD card, you will need to unmount both of them:
sudo umount /dev/sdb1
`
sudo umount /dev/sdb2`
Now you are able to write the original image to the SD drive:
sudo dd bs=4M if=~/SDCardBackup.img of=/dev/sdb
The bs=4M option sets the 'block size' on the SD card to 4Meg. If you get any warnings, then change this to 1M instead, but that will take a little longer to write.
Again, wait while it completes. Before ejecting the SD card, make sure that your Linux PC has completed writing to it using the command:
sudo sync
Last updated