Help with a little dd damage!

John Summerfield debian at
Thu Feb 28 00:59:53 UTC 2008

Morgan Read wrote:
> Hi Folks
> This post could equally be titled - is there a God?
> Yesterday I ran this command:
> [root at morgansmachine DiskBUImagesEtc]# dd if=/dev/sda 
> of=pocketpc.rescue bs=1M count=33
> (No output, just bash history.)
> Today I ran these commands:
> [root at morgansmachine DiskBUImagesEtc]# dd if=/dev/sda 
> of=2ndstage.rescue bs=1K count=1280
> 1280+0 records in
> 1280+0 records out
> 1310720 bytes (1.3 MB) copied, 0.0535238 s, 24.5 MB/s
> [root at morgansmachine DiskBUImagesEtc]# chown morgan: ./2ndstage.rescue
> [root at morgansmachine DiskBUImagesEtc]# dd 
> of=/dev/sda
> 2348+0 records in
> 2348+0 records out
> 1202176 bytes (1.2 MB) copied, 0.117155 s, 10.3 MB/s
if you copy that many bytes back from your rescue, and your rescue 
didn't get clobbered by the misadventure, you should be about okay, but 
you won't really know until you reboot.

A hot backup like that of an active drive is flaky, and a hot restore is 
flaky, so we're looking at flaky squared. Dithering around asking for 
advice probably gave time for the flakiness to byte.
> [root at morgansmachine DiskBUImagesEtc]#
> Both yesterday and today I should not have used /dev/sda, but should 
> have used /dev/sdc...  Ouch...
> Now I seem to have an unallocated partition of some 37.26GB where once 
> existed my carefully constructed laptop hard drive.
> Everything seems to be running fine, but I expect if I reboot - I 
> wont!  I guess I've just wiped out my MBR or something close.

If you restore the first sector, you will have a good partition table. 
You might have filesystem problems, and they may be irrecoverable, you 
won't know until you try it. You can assess it by running fdisk against 
your backup file, a bit like this:
Disk /dev/hda: 40.0 GB, 40016019456 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        4865    38973690   8e  Linux LVM
09:46 [summer at numbat ~]$

On this drive I have 14 blocks before the start of the first partition. 
If you haven't clobbered the first partition, you will be in good shape 
of you resore the MBR, the first sector. The drive might not boot, but 
that's fixable by reinstalling grub.

If your first effort fails and you're about ready to reinstall and write 
off the disk, use Knoppix for your further recovery efforts, it has a 
more complete toolset than Fedora rescue CDs.

I don't know about Fedora Live media.
> So, fingers firmly crossed, have I managed to copy enough of my hard 
> drive with the first two commands to be able to patch back the 
> catastrophic damage I seem to have done with the last command.  Could 
> someone more confident than I give me some instruction:)
> Any help desperately welcome.
> Regards,
> Morgan.

More information about the fedora-list mailing list