Child pages
  • Add a GRUB entry for a Windows installation residing on a separate disk
Skip to end of metadata
Go to start of metadata

If you have a disk inside your machine that contains a working copy of Windows and you don't want to change BIOS settings every time you want to use it, you can add an entry to GRUB in order to boot from it.

In essence, you are having GRUB pass control to the NTLDR bootloader using a procedure called chainloading.

You need to:

  • have administrator privileges on the machine
  • know the order of the disks as seen by the BIOS

First, we find out where the menu.lst file resides. We do this using the bootadm list-menu command:

bootadm list-menu
user@machine:~$ bootadm list-menu
the location for the active GRUB menu is: /rpool/boot/grub/menu.lst
default 0
timeout 10
0 OI_151a8-6

Then we use our favorite editor to open that file with privileges and add an entry like so (added lines are preceded with >> in this example):

menu.lst
splashimage /boot/grub/splash.xpm.gz
foreground 343434
background F7FbFF
default 0
timeout 10
#---------- ADDED BY BOOTADM - DO NOT EDIT ----------
  
#---------------------END BOOTADM--------------------
  
title OI_151a8-6
bootfs tpool/ROOT/OI_151a8-6
kernel$ /platform/i86pc/kernel/$ISADIR/unix -B $ZFS-BOOTFS
module$ /platform/i86pc/$ISADIR/boot_archive
#============ End of LIBBE entry =============

>> title WindowsXP
>> rootnoverify (hd0,0)
>> makeactive
>> chainloader +1

WARNING: do not edit other entries, as this may render the system unbootable.

We use rootnoverify and point it to the first partition of the Windows disk (in this case, the first BIOS disk)

Important: if you had the Windows disk as your first BIOS disk when you installed Windows, you must add another command after rootnoverify but before makeactive:

map
map (hd2) (hd0)

This is necessary because otherwise the NTLDR gets confused about the order of the disks and fails to load. (This useful tidbit comes from here).

When you have entered all the necessary information and saved the file, try using the bootadm list-menu command again to make sure it's correctly readable.

How do I find the GRUB name for the disk?

There's surely a better way out there, but I've found that if you boot the system to the GRUB menu and drop to the GRUB command line (pressing "c" before it boots an entry), you can try issuing the root (hdX,0) command, where X is the disk number, and GRUB will complain about an unknown partition type.

In doing so however it outputs a useful hex number for the partition type. We are looking for number 0x7 for NTFS.

Once you found it, you can try issuing the rest of the commands until you get a successful boot.

  • No labels