It is possible to change the default entry to the last option selected when Grub4dos was previously booted by using the default command followed by a file. E.g. -
The command default (hd0,0)/default specifies that an entry be written to the file default, on the first partition of the first hard disk (this file must be copied from the Grub4dos download – do not edit the file as it must remain 2048 bytes in size). If using this option, the drive containing the default file must be writable. The menu entry must also include the command savedefault – e.g.
To restrict access to the command line interface use the command password prior to any menu entries – e.g.
When booting Grub4dos with a password protected configuration file the default instructions will change from -
to -
The user enters the [p] key to gain privileged control, followed by the specified password – which in the preceding example is administrator.
It is possible to use an encrypted password by using the command password --md5 followed by the encrypted password – in the following case “$1$ZjU0$k107noL9DOaClJEu6n6f91” is an encryption of administrator.
WARNING - do not generate your 'md5 hash” password using another program as it is unlikely to be compatible with Grub4dos (see here). To ensure compatibility use the md5crypt command from within Grub4dos - see below.
To create an encrypted password, boot Grub4dos and press [c] to access a command line interface, then type the command md5crypt - this will prompt you to enter a password and will output the chosen password as an md5 hash (see figure 5. below).
It is also possible to restrict access to individual menu items when a password has been set by using the lock command, until the user enters the correct password (using [p] key to gain privileged control, followed by the password) any menu items designated with 'lock' will not be accessible -
Alternatively the password command can be used to protect individual menu entries by specifying the password command within the entry – e.g.
md5 hash’s can also be used within menu entries. Different menu entries within the same configuration file can be protected with different passwords - whilst still using a password entry at the start of the configuration file forcing the user to enter a password to Press 'p' to gain privileged control - e.g.
It is possible to create sub menus by using the configfile command, followed by the filename of the configuration file you want to load. E.g. menu.lst contents –
Will load submenu.lst. The submenu.lst configuration file follows the same format as menu.lst – a new menu colour scheme can be specified, default boot entry can be set, etc. Adding an option to return to the previous menu is recommended, to avoid being 'stuck' in the submenu.
The command find --set-root combined with a filename can be used to locate a marker file on a device and set that device as the root for all further commands within the menu entry (or all further commands executed from the command line). E.g. –
The example above will search all supported partitions/devices for the file hdd.tag and will set the first device it finds, containing hdd.tag, as the root device. The partition boot sector of the device (chainloader +1 = first sector of current root device) will then be chainloaded.
It is possible to locate and load operating systems in this way. If for example Windows XP is installed, the following entry could be used -
If using the above example it is assumed that the NT loader ntldr is only present on one device. If multiple devices contain ntldr, the first one found will be set as the root device. As this could lead to the wrong installation booting, searching for unique tag/marker files are preferred. Devices are searched in the order –
Please note that ntldr (and other Windows loader/system files bootmgr and io.sys) must be on a partition on device (hd0), or Windows will not boot - see here for a full explanation and workaround.
It is possible to exclude floppy devices (or cd devices) from the search by using the command --ignore-floppies (or --ignore-cd) - e.g. find --set-root --ignore-floppies /ntldr.
REMEMBER - find --set-root sometimes leads to unexpected behavior - e.g. if you have used the map command and the drive you are expecting to find the file on is no longer visible in Grub4dos. Always remember that the search stops with the first instance of the file you are scanning for. Even using marker files can result in unwanted behaviour if you had forgotten (or didn't know) that the file was on more than one device.
The operator && can be used to execute a second command if the first command is executed without error. The operator can be used to execute a second command if executing the first command results in an error. From README_GRUB4DOS.txt -
Some pratical examples are included in grldr's embedded menu and in the sample menu.lst file included in the Grub4dos download.
The entry find --set-root --ignore-floppies --ignore-cd /menu.lst && configfile /menu.lst (from the embedded menu) will execute find --set-root --ignore-floppies --ignore-cd /menu.lst (the root of all (hd) type devices will be searched for menu.lst and the first device found containing menu.lst will be set as the root device). If this part of the command completes successfully then the command configfile /menu.lst will be executed.
The entry map /pmagic.iso (0xff) map --mem /pmagic.iso (0xff) (from the sample menu.lst) will execute map /pmagic.iso (0xff) (mapping the cd image file pmagic.iso as the virtual device (0xff)). If this command fails (if for example the image is non-contiguous) then the second part of the command map --mem /pmagic.iso (0xff) will be executed.