Testdisk saved my Ubuntu bacon

Last week I got my Dell D820 running Windows XP set up to be dual-booted to Ubuntu. I used Ubuntu 5.10 (Breezy Badger) because that’s what I had handy. I was following Mathew J. Miller’s excellent instructions on how to do it.

My only problem came when it was time to install the boot loader. I had forgotten (or chose to ignore) the little partition that Dell puts on their hard drives. That meant that my Linux partition was actually number 2 (the third partition) instead of partition number 1 (the second partition) which is, unfortunately, where I told it to put the boot loader. Partition number 1 is my Windows XP partition–exactly where I did not want the boot loader written to.

And neither did Windows XP. On restart I got the dreaded “Missing operating system” error. “Thanks for the new laptop. Look what I did!”

I had used the Ubuntu Live CD to run QTParted to successfully partition my hard drive so I thought it might be able to get me out of the jam. But after the erroneous boot record write, QTParted didn’t want to have anything to do with that partition. It just threw up its hands.

I booted to the Windows XP Recovery Console and ran fixmbr as well as fixboot but neither of those were effective.

Fortunately, for times like these, there’s testdisk. Testdisk is a wonderful little utility freely-available under the GPL that can recover Windows, Mac, and Linux partitions. I booted into my Ubuntu Live CD, used apt-get to install testdisk (sudo apt-get install testdisk) and fired it up. I then disabled the “bootable” flag on the Linux partition and made my Windows XP partition bootable-primary. When I restarted, Windows XP was alive and well again.

I thought about leaving well enough alone–I was leaving for a client site the next day–but my success bolstered my partition recovery confidence. I formatted the Linux partition and re-did the Ubuntu install paying closer attention to the boot loader step. That time everything went off without a hitch.

I’m still getting used to Ubuntu. It’s a bit different than RHEL but overall I think it’s going to work out.