ADAM'S WEB PRESENCE

15 April 2004

Drunk in charge of a UNIX command line

Filed under: General — adam @ 12:23 pm

Well, I just wanted to write an image to a floppy disk. This is something I’ve done many times before so you’d think I’d be able to do it without any problems but I’d had too many beers so instead of typing:

dd if=boot.img of=/dev/fd0

I typed:

dd if=boot.img of=/dev/hda

In an instant, this completely trashed my MBR, partition table and the first 1.44 megabytes of my NTFS boot partition.

I am now convinced that ‘dd’ is an acronym for “Disk Destroyer”.

I was up until late last night trying to recover stuff. Fortunately, most of my important data is not on the NTFS partition so I only needed to restore the partition table and I could access it again.

How does one restore a partition table ? Well, lucky for me, I found a nifty ware called MBRwork which will scan your drive and rebuild it. It only recovers Windows partitions but that is OK, there’s nothing on my Linux partition that I don’t have a copy of somewhere else. MBRwork found my FAT32 data partition but could not find my boot partition since it was now no longer a valid NTFS filesystem.

Tom’s RootBoot disk made it easy to hand-hack the partition table and fix it up to some semblance of normalcy - that is one really useful tool! Now my NTFS partition exists again but the superblock is scragged so I can’t read the files.

I just reinstalled Linux ‘coz it was quicker and I was going to change from RedHat to Debian anyway.

But there was still some stuff on that NTFS partition which I wanted. So I spent about six hours yesterday trying every NTFS file recovery utility I could find on the net. None of them could find so much as a readme file on my partition.

So I gave up and just began to reinstall Windows XP onto the corrupt NTFS partition. Imagine my surprise when the XP installation procedure offered me the options of running “Recovery Console”. I thought, what the heck and ran it.

Well, the Recovery Console has an option to rebuild the MBR and superblock of a corrupt partition. I gave it a spin and it worked. ChkDsk managed to fix up the rest of the errors and I could see the directory again. Recovery console doesn’t let you copy files easily though, so I just rebooted into Linux and used that to copy my files off the damaged partition.

Then I reformatted the NTFS partition and installed XP. It’s all up and going now and I have breathed a big sigh of relief. Who could imagine such a small thinko at the UNIX prompt could cause so much damage!

Now to install all my applications and maybe I’ll even be able to get some work started before 5pm.


Powered by WordPress