Dual Booting Linux and MS Windows

Although I use almost exclusively Linux, I also have to keep MS Windows on some computers. Therefore, those computers are configured to dual boot Linux and MS Windows. This howto describes the dual boot configuration on Linux/MS Windows XP boxes.

I leave MS Windows XP on the first partition of the hard drive (/dev/hda1) in order to save myself troubles in case of Windows' reinstallation. For the same reason I do not want to overwrite the Master Boot Record holding Windows' loader, therefore I place LILO (or other boot loader) in the boot record of /dev/hda2 partition which I mount as /boot. LILO installation is described in the LILO mini-HOWTO.

After installing LILO, you need to add Linux to XP's boot options. Copy the boot sector of /dev/hda2 partition into a file:

dd if=/dev/hda2 of=bootsect.lnx bs=512 count=1

This supposes that you are working from Linux. Change /dev/hda2 to whatever partition you installed LILO to.

Copy the file bootsect.lnx to the windows partition (/dev/hda1 in this example). I mount the /dev/hda1 partition from Linux but you can also save the bootsect.lnx to some media readable from XP.

In the last step, reboot into XP and log in with administrator privileges. Start a command window from the Run Program menu by typing cmd.exe.

cd c:\
attrib -h -s -r boot.ini

Now you can see and edit boot.ini.

edit boot.ini

Add the line c:\bootsect.lnx to the file and set the attributes back to hidden, system, read-only.

attrib +h +s +r boot.ini

The configuration is finished. XP will now offer booting to Linux or Windows whenever you reboot. Do not forget to create new bootsect.lnx when you update the kernel or LILO.