Clone or Backup an SD / SDHC / Micro SDHC Card / Media on Linux
I wanted to move my Raspbmc installation to a faster SDHC card for my Raspberry Pi, a complete reinstall would be silly, unless you have tons of time to waste. Easy way is cloning! Cloning is good way to backup bootable Micro SDHC or SDHC etc. cards (these cards are notorious at failing without notice).
Items that one may require:
- A Linux PC (Ubuntu, Fedora etc.)
- Card reader(s)
- Card to be cloned
- Hard drive space (optional)
While one can do a direct card to card clone, I prefer first cloning an image of the card to hard drive and then transferring it over to the target card. I would tell you how to do direct card to card cloning at the end.
Insert the card to be cloned or imaged in card reader hooked to your PC. Now we need to identify the name assigned to the sd card in the /dev directory. I find it by using the following command in a terminal:
sudo fdisk -l
This lists out all the disks / drives attached and their details (partitions etc.), inserting an 8GB SDHC card shows details as shown below, it is the /dev/sdb that we are interested in.
Disk /dev/sdb: 7742 MB, 7742685184 bytes
4 heads, 32 sectors/track, 118144 cylinders, total 15122432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002c475
Device Boot Start End Blocks Id System
/dev/sdb1 4096 147455 71680 c W95 FAT32 (LBA)
/dev/sdb2 151552 15122431 7485440 83 Linux
Now we can dump / backup the image of the above SDHC card by running the following command
sudo dd if=dev/sdb of=/home/linux-user/sd-card.bin
Once you run this command, depending on the size and speed of the SDHC card being cloned, it would take a few minutes to several minutes. You can check the progress by browsing to the folder and checking out the size of the file being written out.
Once the process is complete you can eject the card and insert the second card which you want to receive the cloned image. Note: The dd command used above does a raw copy of data including all partitions etc., it doesn’t check for the size of the target to which the image is being copied. The point that I am trying to drive in is that the target media should have greater or exactly equal space as that of the media that you used to create the image. One way to ensure this is that your source and destination media are identical in every possible respect, right down to the manufacturer and the batch they came from. Else you can always clone it to a larger capacity media, but you would loose the remaining unused space beyond the cloned image (this can be fixed using Gparted, more on this later).
In my case the target media receiving the clone, though of same capacity (8 GB) had slightly great available space, so it all went well. I transferred the backed up image using the following command:
dd if=/home/linux-user/sd-card.bin of=/dev/sdb
This step would probably take longer than the previous one, because now you are writing image to the card, as you would know, reading is always faster than writing for all media. That is all, using a couple of ridiculously easy commands I was able to transfer my Raspbmc to a new faster card.
You might also like
|DIY Multimedia / Photo / Video Frame Using Raspberry Pi Long long ago...||Casio High-Speed Exilim EX-FC100 Casio High-Speed...||BeagleBoard XM Powered File Server Using Ubuntu Single Board...||Stream Live TV to Several Computers on LAN Streaming of...|