Tuesday, May 17, 2011

Booting a Windows OS using GRUB

Booting a MS Windows OS using GRUB is a quite simple process. However, we must follow some rules in order to succeed. The first and foremost rule is:
* Windows OS always wants to be installed on a first hard drive and first partition.
* if you have your windows installation on second hard drive you need to use grub’s map command to re-map first hardrive as seccond and vice versa
Grub’s Naming convetion
Grub starts its hard drive and partition numbering system from 0. This means that (hd0,0) refers to a first hard drive and first primary partition. Whereas, (hd2,2) refers to third hard drive and third primary partition. All extended partitions starts from number 4. Therefore, (hd1,5) refers to a second hardrive and second extended partition.
Booting a Windows OS with grub
In case you have indeed installed your MS Windows on a first hard drive and first partition the whole process is rather simple. Open up a Grub’s menu config file:
vi  /boot/grub/menu.lst
and add a following code into appropriate boot menu section :
title           Microsoft Windows XP Professional
root    (hd0,0)
chainloader     +1
save file and run command:
# update-grub
and you are done.
* root: the root partition of your MS Windows installation
* title: title name as it will be displayed on grub’s boot menu
* makeactive: make this entry bootable
* chainloader: do not boot but let partition’s boot loader to boot instead
In case you have a MS Windows installation on a third hard drive, things are little bit more complicated. Here is a /boot/grub/menu.lst code for booting a MS Windows from a third hard drive and first partition.
title           Microsoft Windows XP Professional
rootnoverify    (hd2,0)
map             (hd0) (hd2)
map             (hd2) (hd0)
chainloader     +1
* rootnoverify: do not mount but execute another command
* map: this makes a third hard drive a first and first hard drive third
After you have updated /boot/grub/menu.lst run:
# update-grub