Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to achieve a system disk backup with an Ubuntu live CD. I used the following command:

dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c > /media/external/image.gz

This seemed to work. To validate that I erased the content of sda, then loaded back from the image:

dd if=/dev/zero of=/dev/sda bs=1M
gunzip -c /media/external/image.gz | dd of=/dev/sda conv=sync,noerror bs=64K

However, the result was no longer bootable.

The results of fdisk -l are equal before taking the backup and after trying to restore it:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util
fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       14594   117220823+  ee  GPT
/dev/sda2   *           1           1           0    0  Empty
Partition 2 does not end on cylinder boundary.

I can't seem to be able to mount the disk either. The filetypes I tried did not work (the original disk is a bootable Mac OS X). I tried hfs, hfsplus, hpfs.

The disk does not show (not even as unmounted) in the Ubuntu file explorer anymore. It was showing before zeroing and the restore attempt.

My main question is: what is wrong in my backup/clear/restore sequence? Shouldn't it copy and restore the whole content of the disk, including boot and whatnot? And do that independently of the format? Can the zeroing be the heart of the problem? What did I miss?

EDIT: I have seen this but it did not help me.

The external disk is NTFS.

share|improve this question
up vote 2 down vote accepted

I think both the sync and noerror options to conv could cause problems. If there are any issues with the reads, then noerror will carry on copying potentially dodgy data. sync states that it will pad nulls to each block depending on the incoming block size.

dd without these options should do a byte for byte copy and error if there are issues.


Definition of sync:

When the conv=sync flag is specified, the dd command pads any partial input blocks with nulls. Thus, the dd command inserts nulls into the middle of the data stream if any of the reads do not receive a full block of data (as specified by the ibs flag). This is a common occurrence when reading from pipes.

share|improve this answer
Removing the conv options at the restore operation did the trick, thanks a lot! My understanding of sync was that dd would then replace erroneous bytes in the input by NULL in the image, therefore keeping the alignment. Noerror would keep dd going in spite of such byte errors. I see now that if there were byte errors in the original disk, these would be NULL in the image, and restoring would try to put NULL back at these erroneous locations. sync in the restore operation should fill in with NULL where the image itself has errors... but since it is an image file on an NTFS filesystem... – Gauthier Oct 18 '11 at 10:31
I am not sure I can make sense of that. Would you care to extend your (valid) answer as to why the conv options in the restore operation create problems? – Gauthier Oct 18 '11 at 10:33
I have excluded a specific reason for this happening because it isn't clear. But consider this: sync is saying that every block read must contain exactly 64k worth of bytes. If the disk system was unable to provide 64k for any reason, it will pad the remainder of the block with nulls, effectively corrupting the data. I imagine this could happen if the disk was busy for example. – Paul Oct 18 '11 at 22:28
Is sync padding only if there is a problem in the source ("provide"), or even in the destination? – Gauthier Nov 2 '11 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .