Argh, I lost my partition table!

(February 27, 2006)

Today, Gentoo Linux 2006.0 has been released. I don’t have tried Gentoo ever before, but the 2006.0 Live CD was said to feature a nice user-friendly installer. Because I was still in my »distro testing« mood (a leftover of the preparations for my presentation at CLT), I decided to give the CD a try.

The CD booted with a really nice and stylish graphical boot screen. There were no real problems, but hardware detection didn’t meet Kanotix’ standards: The NIC wasn’t initialized (although the driver has been loaded), sound was missing and my two TV cards were not detected. Not that it matters, I wasn’t going to need either of these anyway, but it shows that some work has still to be done. Remember, one of the purposes of a live CD is demonstrating the capabilities of the system being presented, and lacking sound support isn’t very convincing.

The installer itself is OK. It’s nothing compared to the beginner-oriented installers I tested the last weeks, but the structure was simple and there were no unclear situations.

The disaster began after clicking the final »Install« button. Just some seconds later, I was told that setting up the partitions failed. Huh? I didn’t tell the installer to set up any partitions in the first place! I just wanted to use /dev/hdb4 as the root partition and keep everything else in place. The log window’s contents were even more disturbing: From there, it seemed like the installer was going to delete partitions, failed, and crashed with a Python exception. I hit hit the reset button immediately and — guess what — GRUB didn’t boot.

Booting with a Kanotix CD and doing a fdisk –l /dev/hdb confirmed my fears: All the partitions were gone, instead of one large FAT32 blob that didn’t correspond to any former partition. However, I already restored a broken partition table (remotely via SSH) on a friend’s computer several months ago. Hence I decided not to get panicked immediately :)

There are two programs that I know of which can be used in such situations (both are available on the Kanotix CD).
The most popular one is gpart, a simple tool which does a quite thorough search on the disk. It took about two minutes to scan the 80 GB disk, and the results were neither correct (gpart completely fails to detect extended partitions) nor directly usable without typing all the addresses into fdisk by hand.

Just like at the last recovery I did, I ended up using testdisk. This nice little program uses a text-based dialog user interface like cfdisk, is incredibly fast and accurate. At first, it refused to write back the detected partition table — it pretended that the resulting scheme would be illegal. A detailed look revealed that the detected partitions were overlapping. Additionally, a warning about 16 vs. 255 heads per cylinder appeared. After manually overriding the detected disk geometry, testdisk suddenly detected all the partitions correctly and happily wrote the guessed table back to disk.

The only thing that changed was the order of the primary partitions, so GRUB had to be re-installed to make it work again. Fortunately, this is a very easy task with GRUB (root (hd1,1); setup (hd0) and off you go), so there wasn’t much hassle with that.

The really cool thing about all that is that Windows didn’t even notice what happened — it booted happily and the D: partition was recognized immediately, even though it »moved« from hdb1 to hdb3.

This doesn’t mean that I’m completely happy now, though: The whole story put me behind schedule with the CLT presentation for another day …

Post a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Captcha: