Friday, September 28, 2007

Wubi Dangers

So yesterday I had a rather tense time trying to help Overlord fix his laptop. He covered the story in his blog but I figured I'd blog the solution we came up with here too for everyone's benefit.

He had installed Wubi (warning: read this first and remember it is an unofficial beta product) on his new laptop and it was all working fine. That is until the next morning when he switched his machine on to find it stuck in a loop running the POST, searching for an OS, failing to find it, and rebooting to start the process again.

The first thing to do was obviously a Google search, which resulted in several hits. The first hit gave us a vital clue: partition boot sector corruption was occurring. After some fiddling this eventually triggered a memory of a similar experience I had once with Wubi causing partition table corruption after a lockup and unsafe reboot. That time I had used a tool to manually recreate my partition table (luckily I didn't have a complex setup) and write a functioning boot sector to the relevant location. That wasn't an option this time as the tool wasn't immediately available, so I suggested my old backup option. This involved using the XP install disc to fix the corrupted boot sector via the Recovery Console. I only had an XP Pro install disc and the installation on the laptop was XP Home, but luckily that isn't an issue for this type of operation. The first thing we tried was chkdsk to find any obvious filesystem errors, but this did nothing. Running map showed why: the filesystem type could not be detected (a previous data gathering mission [not mentioned above] with an Ubuntu Live CD was able to extract the filesystem type strangely). Knowing that the most likely cause of the troubles was the partition boot sector being corrupted, the next program to run was fixboot, which confirmed the corruption, detected the filesystem as NTFS, and wrote out a new (supposedly working) copy of the boot sector. With fingers crossed we rebooted and waited... only for it to continue happening. Suppressing some combination of cursing and tears we booted once again into the Recovery Console for another try. Again the first thing to be run was chkdsk and this time it actually did something and mentioned fixing some errors, though it didn't say what they were. At this point I was silently praying it knew what it was doing because if it had picked up the wrong filesystem type it could be happily trashing the files on it. map was then run again and still no filesystem type being shown for that partition ("I have a bad feeling about this", praying again I wasn't right about chkdsk being bad). As a last ditch we ran fixboot again (again, seriously, fixing this was enough to induce OCD in someone) and then map and... WOOT! The filesystem was shown as NTFS. Crossing our fingers again for the reboot we waited for the POST stuff to happen and then... Windows. Lovely lovely Windows. I never thought I'd say that. Overlord understandably purged all trace of Wubi from his system and vowed never to use it again.

I think the magic combination was the fixboot-chkdsk-fixboot, though I can't be sure. I certainly don't want to have to do this again.

I should note that I am using Wubi on my machine here (not only that, but running Ubuntu Gutsy beta under it) and I have only had the problem resulting from the lockup-reboot, but I may very well have just been lucky. Basically, an OS with reverse-engineered drivers for a badly documented filesystem with no journalling/transactions available running under a beta installer/loader isn't the best thing to have on your machine. You have been warned.

No comments:

Post a Comment