Gunzip truncates dd.gz file to zero size .dd file? Trailing garbage ignored?
Hi,
I am using DD to backup entire system partitions and now I am trying to restore one. The resulting disk image from my buggy process has zero bytes. D'oh!
I wrote a Perl script to write zeros to unused space on the partition and then piped the dd output to gzip to reduce the size. Here's part of the log file:
Cmd "cd /mnt/sda2.u904.sys; /bin/dd if=/dev/zero of=zero.file bs=1000000 count=26951" -> 4.683 minutes.
Cmd "ls -l /mnt/sda2.u904.sys/zero.file; df | grep /mnt/sda2.u904.sys" -> -rw-r--r-- 1 root root 26951000000 2010-06-17 18:46 /mnt/sda2.u904.sys/zero.file
/dev/sda2 41286828 37829520 1360028 97% /mnt/sda2.u904.sys
So, it looks like I have successfully loaded the partition up to 97% full by zeroing free space. Then I just remove the file.
Here's the part which I suspect is buggy:
Cmd "/bin/dd if=/dev/sda2 conv=sync,noerror bs=64K | gzip --to-stdout > /tera/trex.sda2.u904.sys.20100617.dd.gz" -> 21.800 minutes.
Size of image "/tera/trex.sda2.u904.sys.20100617.dd.gz" = 7.891 E9 B.
Total elapsed time = 26.52 minutes.
26 minutes to read and compress 11 gigs of system data down to 8. Sounds reasonable.
Here's the bad part trying to restore an old .dd.gz file:
-rw-r--r-- 1 brianp vboxusers 6.3G 2010-05-04 10:06 /r5/trex.sda2.20100504.dd.gz
brianp@trex:/tera$ cp /r5/trex.sda2.20100504.dd.gz /tera/bak
brianp@trex:/tera$ gunzip bak/trex.sda2.20100504.dd.gz
gzip: bak/trex.sda2.20100504.dd.gz: decompression OK, trailing garbage ignored
brianp@trex:/tera$ cd bak
brianp@trex:/tera/bak$ ll *504*
-rw-r--r-- 1 brianp vboxusers 0 2010-05-04 10:06 trex.sda2.20100504.dd
It apparently thinks the image was trailing garbage and ignores it. It deletes the original file and replaces it with a zero byte .dd file.
I have the original copy of the image in a dd.gz file. It's 6.3 GB so it may still contain the data.
How do I get the original image back without destroying it again?
Thank you,
BrianP
|