I made an image of a complete disk with :

$ sudo dd if=/dev/sdc | gzip -c > my_image.dd.gz

When I restore it with :

$ gunzip -c my_image.dd.gz | sudo dd of=/dev/sdc

I get errors when I type :

$ sudo sfdisk -l

Output of sfdisk :

Disque /dev/sdc : 1022 cylindres, 247 têtes, 62 secteurs/piste
Unités= cylindres de 7840768 octets, blocs de 1024 octets, décompte à partir de 0

   Périph Amor Début     Fin   #cyls    #blocs    Id  Système
/dev/sdc1   *      0+    637-    638-   4881408   83  Linux
                début : (c,h,s) attendu (0,33,3) trouvé (0,32,33)
                fin : (c,h,s) attendu (637,158,50) trouvé (607,212,53)
/dev/sdc2        637+    892-    256-   1952768   83  Linux
                début : (c,h,s) attendu (637,158,51) trouvé (607,212,54)
                fin : (c,h,s) attendu (892,166,20) trouvé (850,240,30)
/dev/sdc3        892+   1022-    130-    995328   82  partition d'échange Linux / Solaris
                début : (c,h,s) attendu (892,166,21) trouvé (850,240,31)
                fin : (c,h,s) attendu (1022,163,42) trouvé (974,218,12)
/dev/sdc4          0       -       0          0    0  Vide

For the non-French speakers : début = beginning, fin = end, attendu = expected, trouvé=found, vide=empty, amor(çable)=bootable

I think it's because I forgot to use the dd option conv=noerror,notrunc,sync when I created the image and the data alignment in the file systems got messed up.

I don't have the original disk at hand. How can I restore the image to a new disk ?


OK, I fixed it. The 2 disks have the same size, but different numbers of sectors per track. As I have access to the source machine over the internet, I could save the partition table :

$ sudo sfdisk -d /dev/sda > smps02_partitions

Once transferred to my local PC, I applied the partition table to the new disk :

$ sudo sfdisk --force /dev/sdc < smps02_partitions

Finally, I could boot into the system.

| improve this answer | |

Your new disk has a different size than the image.

After applying the image with dd, you can use some third party disk management tool (e.g. gparted, also available as a bootable usb stick) and try to resize/repair the partition so it fits the new disk.

another way would be to somehow mount the disk image and only extract the partition content you need.

EDIT: just in case anyone else has this problem here is a more elegant solution. you can mount a partition within a dd image, instructions on this can be found in this post https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device then partition your new hard drive as usual, and copy the files from the mounted image on your new drive.

in your case you also need to extract it from the gzip file.

i assume that you only have user data in the partition, if its system files like config files from /etc, you also need copy the security information.

| improve this answer | |
  • I did try GParted, but it could not repair the partitions. – dplamp Apr 8 '14 at 9:55

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.