Cloning Image to another card


I prepared Linux system in the SD820C board, loaded with all packages i need.
How can i clone the whole image of the working card to another card ?


On Linux you can easily clone an SDCARD with cat or dd.

example (replace sdcard device with your own /dev/sdX):

# Save sdcard to a file
dd bs=4M if=/dev/sdb of=./sdcard.img
# Write saved image to a sdcard
dd bs=4M  if=./sdcard.img of=/dev/sdb


# Clone sdcard1(/dev/sdb) to sdcard2 (/dev/sdc)
dd bs=4M if=/dev/sdb of=/dev/sdb

But I would also suggest you to look at the following topic, which explains why it’s not recommended to cloning an already ‘initialized’ system:


This is not exactly what i want.
I would like to dump the image from the eMMC, as is, and burn it to another card.
I can dd read sda from the source card (is it enough) , but how can i burn it then to the eMMC of another card ?
I can’t write sda of working system.


Hi @salex,

For your usecase, you can use the below steps:

  1. Extract the current image using dd:
    $ dd if=/dev/sdx of= ./raw.img bs=4M

Note: Replace /dev/sdx with RootFS partition.

  1. Convert the extracted raw image into sparse image using img2simg utility:
    $ img2simg raw.img system.img
  1. Finally you can flash the system.img using fastboot.

Beware that by doing the above steps, you can easily messup with your RootFS (please see the thread which @Loic mentioned)

Hope this helps!



I think if you have qualcomm download tool(QFIL), you can read images from device, then move it to sd card.


Hi @Mani,

This way is pretty easy, when i saw it i thought it is too good to be true.
Practically it didn’t worked for me.
May be i’m doing something wrong. Here is the operations:

  1. Read source card image (command run from remote ubuntu machine)

ssh linaro@ “sudo dd if=/dev/sda” | dd of=image1.img

resulting image size 24.5 GB
2. Convert to sparse:

img2simg image1.img image_sparse.img

resulting image size 13.3 GB
3. On the tarfet card, enter fastboot mode and burn

sudo fastboot flash rootfs image_sparse.img

The result was:

Target reported max download size of 536870912 bytes
sending sparse ‘rootfs’ (520735 KB)…
OKAY [26.070s]
writing ‘rootfs’ …
FAILED (remote:size too lirge)
finished total time: 26.084s
Am i doing something wrong ?



Hi @salex,

Target reported max download size of 536870912 bytes
sending sparse ‘rootfs’ (520735 KB)…
OKAY [26.070s]
writing ‘rootfs’ …
FAILED (remote:size too lirge)
finished total time: 26.084s
Am i doing something wrong ?

This could be because, dd will create an image equal to the size of the partition. In this case, since rootfs partition is ~24G, the resulting image is also the same size.

To overcome this issue, you can use the resize2fs utility on the raw image to shrink the size of the image (don’t worry, your data will be safe) and then convert it to sparse image and flash.



The commands above will have backed up the partition table as well as the root partition itself. This makes the image too large to copy to other devices (and also prevents you from running filesystem aware tools on it).

Use /dev/sda1 instead of /dev/sda to backup just the rootfs.

Also it would be a good idea to use ext2simg instead of img2simg to prepare the image for fastboot. ext2simg will write faster (and cause less wear on your flash) because it will not write unallocated space.


Hi @Mani,
I’m trying to run resize2fs on the image i got according to @danielt recommendation.
I get following error:

resize2fs: Filesystem has unsupported read-only feature(s) while trying to open image1.img
Couldn’t find valid filesystem superblock

Why ?



It looks like resize2fs doesn’t recognise it as filesystem image. Try running tools like file on the image to find out what is actually in it.


@danielt, @Mani
Thank you for your help so far.
I have partial success.
On my Ubuntu 14.04 i had to compile latest (for that system) version of resize2fs (1.43), then it performed the resize.
After resize2fs and img2simg i burned the image with fastboot, but it boots only on serial connection and logs in automatically as root.
After that i can switch user, or connect to the card with ssh as linaro.
When i try to boot it regularly, as linaro user, the card doesn’t goes up.
Looks like permissions problem or some start up driver is corrupted.
How can i solve it ?

Update: It works.
I found that if the UART wires are connected to the USB-TTL dongle (even if the dongle is not connected to the PC), the system is not starting correctly. That was happened to me.

Thanks for the help.



Does the board you are cloning from run the same kernel version and the board
you are cloning to?

Both boards need to be installed with the same snapshot for rootfs cloning to
be reliable.


If i understand your question, the kernel should be compatible because of boot loader and partitioning.


I’m afraid I don’t understand the answer either!

The board that you copied the rootfs from would have been running a snapshot build of some sort.

Did you install the same snapshot build to the other board before attempting to write the custom rootfs?