0

I have a bootable sd card with OSMC on for my raspberry. I want to buy another and better sd card and i dont want to write and configure the OS again. Is there a way to extract the image from the current sd card (and then write it to the new one)

1
  • Have you tried dd to clone it? – rocket_doge_ Jan 31 '17 at 18:55
2

You can clone the sd card with DD.

Make sure the target card is at least as big as the source card.

A command to watch the progress of the copy is:

$ dd if=[source drive or image] of=[destination drive or image] bs=4M status=progress

The source or destination drive or image can be replaced with one of the following examples:

  • /dev/sda
  • /dev/sda1
  • /dev/sdb
  • /dev/sdb1
  • /home/user/disk.img

The above are examples. To backup the whole disk if source drive were /dev/sdb and the destination drive were /dev/sdc the command would be:

$ dd if=/dev/sdb of=/dev/sdc bs=4M status=progress

If you backed up to an image, you could use the image as a permanent backup and eventually make multiple clones from the image.

$ dd if=/home/user/disk.img of=/dev/sdc bs=4M status=progress

The number after in the device is the partition, in case you are only concern with cloning a partition rather than the whole drive.

It's very important to be careful with this low level command... especially the of (output part). Without checking it'll start to write to the destination device which could corrupt your system if you output to the wrong device, your main OS or Data drive for example.

What I do in an effort to be careful is create a script for the process. Then run the script when I have spent a lot of time studying it to be sure I'm accessing the correct devices.

Hitting cntrl-C will drop out of the command, but it will not stop the process. You have to specifically kill the dd task.

After the clone, if there is a discrepancy in size (for instance the destination disk or partition is bigger, you can fix this with gparted by resizing the partition on the new drive.

2
  • So when you want to back up your image you have if=/dev/sdc and of=/home/user/disk.img . Where sdc is the raspberry card without partition number? – k_kaz Feb 1 '17 at 7:54
  • 1
    Yes. I included the partition number in the description for explaining the how **dd works. But yes, in your case you want the whole device to be backed up or restored. – L. D. James Feb 1 '17 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.