The first step is to edit /etc/grub.d/40_custom
(using sudo
) and add the following lines to the bottom of the file:
menuentry ‘Windows 7′ {
set root=’(hd0,msdos2)’
chainloader +1
}
Since the location of the Windows installation can differ widely, I need to explain the “set root” line because (hd0,msdos2) refers to /dev/sda2 on my machine.
More generally, hd0 (or /dev/sda elsewhere) refers to the first hard disk installed in any PC with hd1 (or /dev/sdb elsewhere) being the second and so on. While I was expecting to see entries like (hd0,6) in /boot/grub/grub.cfg, what I saw were ones like (hd0,msdos6) instead with the number in the text after the comma being the partition identifier; 1 is the first (sda1), 2 (sda2) is the second and so on. The next line (chainloader) tells GRUB to load the first sector of the Windows drive so that it can boot. After all that decoding, my final comment on what’s above is a simple one: the text “Windows 7″ is what will appear in the GRUB menu so you can change this as you see fit.
After saving 40_custom, the next step is to issue the following command to update grub.cfg:
sudo update-grub2
Once that has done its business, then you can look into /boot/grub/grub.cfg
to check that the text added into 40_custom
has found its way into there. That is important because this is the file read by GRUB2 when it builds the menu that appears at start-up time. A system reboot will prove conclusively that the new entry has been added successfully.
Credits go to: http://technologytales.com/2010/11/21/manually-adding-an-entry-for-windows-7-to-an-ubuntu-grub2-menu/
Or check: Add Windows 7 to boot menu