How to Clone a SD Card on Linux

The following article describes how to use the DD command to make a raw copy of your SD card or Media Disk

First make sure you have as much room on your hard drive as the size media you’re using.

You can confirm this with the simple “df” command. So just open a terminal window and type df, and you will see how much space you have available per partition on your system.

Next, you need to identify the name of your sd card in the /dev directory. Its hard to do, and the little bit of detective work necessary to make it easy is simply to pop your sd card (and card reader) into a port, and then go to a terminal window and type:

dmesg | tail

What this does is it pipes your device messages into the tail command, showing you the last 10 device messages you’ve received. One of them will be the one created by popping the SD card in, and will probably look something like:

[ 335.316290] sd 3:0:0:0: [sdb] Attached SCSI removable disk

 

This is your smoking gun. It’ll probably be the last entry. And this gives you the device name that you will use in the dd copy command.

Now that your SD card s installed and you know that it is called /dev/sdb (or whatever), you can go ahead and copy the entire raw disk image to your hard drive. If you have 2 SD card readers, you can eliminate this step and go right from card to card. But I don’t, so here’s the copy-to-harddrive command.

dd if=/dev/sdb of=~/sd-card.bin

 

You might have to be root to do this, so you can sudo su and issue the above command, or optionally:

sudo dd if=/dev/sdb of=/home/mike/sd-card.bin

Just remember where you’re putting the file. It’s possible to open that folder through the GNOME desktop and do refreshes to see the size of the file grow. Mine went up to 1.8 GB before it finished, and took quite a long time.

Put the new media into your SD card reader, and reverse the command. Of course be sure that your source and destination media are identical, right down to the manufacturer and the batch they came from, if at all possible. This is probably best accomplished by buying them all at once, or part of a multi-pack. This is a raw copy akin to a floppy disk or CD-ROM copy, and of course all floppy disks and CD-ROMs are basically laid out the same. But that is not true of SD cards that have many differences, so the more identical the source and destination media you use, the less grief you will cause yourself.

dd if=/home/mike/sd-card.bin of=/dev/sda

 

If this command seems ridiculously easy, it is. It’s just a long wait. And considering how easy it is, setting yourself up with an Ubuntu box just for this purpose is really the path of least resistance, compared to trying to do it on a PC with Norton Ghost or using some other paid software, or even setting up Cygwin on your PC. Just have a Linux box around for these types of things. It will help you immensely over time with the whole ShankServer thing.

 

 

 

 

Password Reset
Please enter your e-mail address. You will receive a new password via e-mail.

Power by

Download Free AZ | Free Wordpress Themes