SD card cloning using the dd command
Insert the original SD card and check the name of the device (usually mmcblkX
or sdcX
):
sudo fdisk -l
You might see:
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 2048 2099199 2097152 1G c W95 FAT32 (LBA)
/dev/mmcblk0p2 2099200 31116287 29017088 13.9G 83 Linux
In my case the SD card is /dev/mmcblk0
(the *p1
and *p2
are the partitions).
Now you have to unmount the device:
sudo umount /dev/mmcblk0
Now to create an image of the device:
sudo dd if=/dev/mmcblk0 of=~/sd-card-copy.img
This will take a while.
Once it's finished, insert the empty SD card. If the device is different (USB or other type of SD card reader) verify its name and be sure to unmount it:
sudo fdisk -l
sudo umount /dev/mmcblk0
Write the image to the device:
sudo dd if=~/sd-card-copy.img of=/dev/mmcblk0
The write operation is much slower than before.
You should not be using dd on mounted devices. unmount all the partitions first, then your command should work.
I am using dd tool to clone usb sticks with multiple partitions, here is my command:
sudo dd if=/dev/sdb of=/dev/sdc bs=4096 conv=notrunc,noerror
notrunc - do not truncate the output file
noerror - continue after read errors