Linux – Cloning an SD card onto a larger SD card

ddlinuxsd card

I'm using Ubuntu 12.04. I have an old 4GB SD card, and have just bought a new 16GB SD card. I would like to copy everything from my old 4GB SD card onto the new 16GB SD card. I was afraid that the usual copy-and-paste trick would miss out something, so I wanted to clone the old 4GB SD card onto the 16GB SD card. I used the dd command in a shell, following instructions in this link.

This worked with one small caveat. The new SD card now appeared to be 4GB. I later found out this is because the primary partition on the 16GB SD card has now shrunk to 4GB. I have solved this problem, and I think I understand it. However, my question now is, how do I clone my old 4GB SD card onto my new 16GB SD card without making the primary partition on the 16GB SD card shrink to 4GB?

Best Answer

You will allways shrink your primary primary partition to the size of the copied one unless you copy the contents of your partitions with dd.

I assume you did something like sudo dd if=/dev/sda/ of=/dev/sdb bs=4k or used an image file as temporary storage if you don't have two SD card slots. With this command you copied the partition as well as the partition table to the new SD card.

Try this (assuming your partitions are called /dev/sda1):

  • put in your 4 GB SD card
  • sudo dd if=/dev/sda1 of=~/sdcard.bin
  • put in your 16 GB SD card and make sure the primary partition spans over the whole 16 GB
  • sudo dd if=~/sdcard.bin of=/dev/sda1

This should copy only the contents of your partitions.


You could also simply resize the partition on your new SD card. If you'd like to have some information on that, you have to tell us which filesystem is used on your SD cards.

Related Question