Restoring a disk image with dd
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.