Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to clone SD card which may contain number of partitions, some of them Ubuntu cannot recognize. Generally, I want to clone the whole volume, not only some partition. So, I mount SD card and see in the Log viewer something like this:

kernel: [  262.025221]  sdc: sdc1 sdc2
alex@u120432:~$ ls /dev/sdc*
/dev/sdc  /dev/sdc1  /dev/sdc2

Since I want to copy the whole disk, I execute:

dd if=/dev/sdc of=sdimage.img bs=4M

File sdimage.img, 7.9 GB (7,944,011,776 bytes) is created (SD card is 8 GB). Now I mount another SD card and execute:

dd if=sdimage.img of=/dev/sdc bs=4M

The problem is that the second dd command hangs on some stage, and never succeeds. After this, I cannot reboot or shut down computer, and need just to switch power off.

Is this correct approach? Maybe there is another way to clone SD card?

OS Ubuntu 12.04, 32 bit.

share|improve this question
    
Can you mount created img file and see if it is created correctly? –  Milan Todorovic Dec 11 '12 at 14:40
    
@MilanTodorovic - how can I do this? –  Alex Farber Dec 11 '12 at 15:15
    
If I remember correctly: mount -o loop sdimage.img /path/to/mount. Then check to see if you can browse img file correctly. –  Milan Todorovic Dec 11 '12 at 15:17
    
@MilanTodorovic: I tried sudo mount -o sdimage.img /dev/mydisk and got: mount: can't find /dev/mydisk in /etc/fstab or /etc/mtab Possibly I need to create some dev entry before. Can you post this as answer with some details? Thanks. –  Alex Farber Dec 11 '12 at 15:22
    
Try with sudo mount -o loop sdimage.img /dev/mydisk (you forgot loop after -o) –  Milan Todorovic Dec 11 '12 at 15:26

3 Answers 3

up vote 8 down vote accepted

You should not be using dd on mounted devices. unmount all the partitions first, then your command should work.

share|improve this answer
    
why is the opposite for me? I've Ubuntu 12.10 and the command has works only with partitions monted... –  Velthune Feb 13 at 10:12
    
@Velthune Are you sure about that? If so, I'd suggest making your own question. –  Vreality Jul 17 at 3:58

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

share|improve this answer
    
Thanks, I will try this. –  Alex Farber Dec 11 '12 at 15:17

dd is fine, but I prefer cat /dev/sdc/ > ~/backup.iso If you want to put it on an SD card again, just run cat ~/backup.iso > /dev/sdc

share|improve this answer
    
Both SD are 8 GB. cat can be used to make SD image, but to make another SD I should use dd, right? –  Alex Farber Dec 11 '12 at 15:17
3  
Any explanation of downvote? If something is wrong in this answer, I want to know. –  Alex Farber Dec 11 '12 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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