Yeah, Windows sucks. It is truly awful. But a necessary evil for myself and many others.

One of the suckiest things is how it refuses to accept that there can be in existence any other operating systems in the world but itself.

So I have a PC and had a Windows and Linux install for some time running together, with grub in the MBR handling the booting both Linux and Windows. Or at least passing booting off to NTLDR to bring Windows up. No problem.

But then I wanted to reinstall Windows in another partition. It is always good to do a reinstall of Windows into a fresh partition so that you can copy over bits and pieces of the old install as you need them (notable stuff in the Application Data folder in your profile). So it was time. My Windows installation had gotten slow and bloated after only six months, as I randomly install software to make the experience more palatable. My new strategy was to run everything from Linux primarily, and do Windows stuff from a Windows VM on my server, and just use native Windows for games.

I did try and use VM Server as a way of reinstalling Windows into the partition without having to leave Linux, by creating a partition based disk for the VM. VM Server reports that the partition table is invalid if you do this on my install. There are a few people who have experienced this before, but none seemed quite the same as mine, and I didn’t get to the bottom of it.

So it was time for a native install. So a PC fairly useless while Windows gets on with copying itself. Except it didn’t work. This was new – most of the problems you get with Windows I have encountered one time or another but this one I hadn’t seen.

The CD would boot, and do the “Checking Hardware configuration” message that precedes the blue install screen, but it never got to the blue. It just cleared the screen and hung.

So.. a bit of a googling (sorry Google for using your name as a verb, but seriously, it is one now) and I discover that Windows XP install will not work if there is a boot sector that it doesn’t know. Ie, if there is one present, and it isn’t a Windows one. Either that or the partition tables aren’t aligned the way it expects.

So a bit of monkeying around later – reorganising the partitions in a way that I did not want, and having to boot the disk with no hard drives connected, I finally got Windows installed. Of course, my boot sector is now trashed with the Windows one instead of grub.

But clearly putting grub back is only going to give me problems next time I want to wipe windows.

The good news is that you can boot Linux – essentially chain grub – from NTLDR – the windows boot manager. There is a stack of articles about it around, and from my experience, GRLDR doesn’t work – this is the grub4dos boot manager that should be able to read and process a standard menu.lst file. The documentation is erratic, and says that it must on the boot drive, but cannot be on NTFS. Not sure how you resolve that if your boot drive is NTFS.

So the other way is to get a copy of the grubbed boot sector, make a file out of it, put it in the root of your boot drive, and just add it to boot.ini.

You need to understand which is your boot drive. In my case grub was installed in the MBR of the primary disk /dev/hda. After all this stuffing around, that had been wiped, so I reinstalled it into another drive:

<br /># grub<br />grub&gt; root (hd0,7)<br />grub&gt; setup (hd0,7)<br />

This will install grub into /dev/hda8 (the eighth partition of the first ide drive – grub itself numbers partitions from zero). If your first drive is SATA, then this may refer to /dev/sda

Now make a copy of the first 512 sectors:

<br />dd if=/dev/hda8 of=linux.boot bs=512 count=1<br />

Copy this to your primary Windows partition – wherever boot.ini resides (usually c:). Then edit boot.ini and put in the line:

<br />c:\linux.boot="Linux"<br />

Reboot, and this will appear in the standard boot menu for Windows.

Wednesday, August 22, 2007

« Back