Grub4dos Guide - Embedded Menu
The Grub4dos files grldr and grub.exe contain an embedded menu, which specifies where to search for the configuration file menu.lst during the boot process. The embedded menu uses the following entries -
default 0
timeout 1
title find /menu.lst, /boot/grub/menu.lst, /grub/menu.lst
errorcheck off
configfile /menu.lst
configfile /boot/grub/menu.lst
configfile /grub/menu.lst
find --set-root --ignore-floppies --ignore-cd /menu.lst && configfile /menu.lst
find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst && configfile /boot/grub/menu.lst
find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst
errorcheck on
commandline
title commandline
commandline
title reboot
reboot
title halt
halt
Breaking down these commands line by line -
- default 0 - specifies that the first menu entry is the default option.
- timeout 1 - this will boot the default menu entry after 1 second.
- title find /menu.lst, /boot/grub/menu.lst, /grub/menu.lst - this is the text that is displayed for the (default) menu entry.
- errorcheck off - this turns of error checking. If errorcheck was left on then the menu script execution would stop on any error, and would for example hang at the next line if menu.lst is not found at the root of the boot device.
- configfile /menu.lst - this will load menu.lst from the root directory of the current root device (the device from which grldr or grub.exe was loaded) if it is present, if it is not then the next line will be processed.
- configfile /boot/grub/menu.lst - this will load menu.lst from the directory /boot/grub on the current root device if it is present, if it is not then the next line will be processed.
- configfile /grub/menu.lst - this will load menu.lst from the directory /grub on the current root device if it is present, if it is not then the next line will be processed.
- find --set-root --ignore-floppies --ignore-cd /menu.lst && configfile /menu.lst - this line contains two separate commands. The first find --set-root --ignore-floppies --ignore-cd /menu.lst will search the root of all available (supported) devices for menu.lst and will set the first device on which it finds it as the new root device (floppy and CD devices are not searched). If the search was successful then the second command configfile /menu.lst is processed and menu.lst is loaded, if it was not then the next line will be processed.
- find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst && configfile /boot/grub/menu.lst - this line contains two separate commands. The first find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst will search for menu.lst in the directory /boot/grub on all available (supported) devices and will set the first device on which it finds it as the new root device (floppy and CD devices are not searched). If the search was successful then the second command configfile /boot/grub/menu.lst is processed and menu.lst is loaded, if it was not then the next line will be processed.
- find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst - this line contains two separate commands. The first find --set-root --ignore-floppies --ignore-cd /grub/menu.lst will search for menu.lst in the directory /grub on all available (supported) devices and will set the first device on which it finds it as the new root device (floppy and CD devices are not searched). If the search was successful then the second command configfile /grub/menu.lst is processed and menu.lst is loaded, if it was not then the next line will be processed.
- errorcheck on - this will turn error checking back on.
- commandline - this will start the command line interface.
To summarise,
(cd) and (fd) devices are not scanned for either grldr or menu.lst, unless they are the boot device.
If grldr is loaded from a (hd) device via Grub4dos code in the MBR or partition boot sector, then the partition from which it is loaded becomes the root device. This partition is scanned for menu.lst at the root of the partition and in the directories /boot/grub/ and /grub/. If menu.lst is not found in any of these locations then all supported hard disks and partitions are scanned for menu.lst (at root and in /boot/grub/ and /grub/ directories) - (cd) and (fd) devices are not searched. If menu.lst is not found then the device from which grldr was loaded remains the root device. If menu.lst is found then the partition from which it was loaded becomes the root device. menu.lst does not therefore have to be contained in the same partition as grldr.
If grldr is loaded from a (cd) device then (cd) becomes root. (cd) is then scanned for menu.lst (at root and in /boot/grub/ and /grub/ directories). If menu.lst is not present in these location then (hd) devices are scanned (at root and in /boot/grub/ and /grub/ directories) - (fd) devices are not searched. If menu.lst is found on a (hd) device then the partition from which it was loaded becomes the root device.
If grldr is loaded from a (fd) device then (fd) becomes root. (fd) is then scanned for menu.lst (at root and in /boot/grub/ and /grub/ directories). If menu.lst is not present in these location then (hd) devices are scanned (at root and in /boot/grub/ and /grub/ directories) - (cd) devices are not searched. If menu.lst is found on a (hd) device then the partition from which it was loaded becomes the root device.
A note from README_GRUB4DOS.txt if loading grldr via ntldr (the NT loader used by Windows NT/2000/XP) - "...ntldr only loads the startup code of grldr (i.e., the leading 16 sectors of grldr), not the whole grldr file". The embedding settings in the startup code consequently scans for grldr in all supported (hd) type devices. If grldr is present on more than one partition then another instance of grldr could be loaded. If for example grldr (the first 16 sectors) was initially loaded from (hd0,3) but grldr was also present on (hd0,0), then (hd0,0)/grldr would be loaded and (hd0,0) would become root.
If menu.lst is not present on the device from which grldr was loaded but multiple menu.lst files are present on other devices (e.g. on (hd0,0) and (hd1,2)) then the first instance of menu.lst is loaded - in this case (hd0,0).