SVBus

GRUB4EFI (GRUB4DOS for UEFI)

This page contains the following sections -


Device Allocation/Numbering

Device allocation/numbering in GRUB4EFI is very similar to GRUB4DOS - see here for more information.

One of the differences in GRUB4EFI is the use of (hd-1) - this device refers to the highest numbered disk on the system. As an example, on a system with three disks (numbered from 0 - disk 0, disk 1 and disk 2), (hd-1) would refer to disk 2. The (hd-1) device is useful when mapping disk images as (hd-1) can be used to select the disk image most recently added to the system.


Fundamentals

GRUB4EFI uses the same syntax and basic controls as GRUB4DOS. To avoid duplication in this guide, see here for more information.


Command-Line

GRUB4EFI uses a similar commandline syntax to GRUB4DOS. To avoid duplication in this guide, see here for more information.

One difference in GRUB4EFI is the use of (hd-1) - refer to Device Allocation/Numbering section for more information.

Another key difference is that GRUB4EFI does not require the use of the map --hook command - a device is automatically mapped following the use of the map command on the command-line or in a configuration file.

To drop into a command shell press [c] if a boot menu is displayed – this is useful for debugging menu.lst entries. If the configuration file is not found a command shell is loaded by default.

To view available commands type help when in the command shell – this will list all commands (see screenshots below).


Installation

Download GRUB4DOS for UEFI from the http://grub4dos.chenall.net/categories/for-UEFI/ site - version 2023-02-23 was used during testing. Extract the following files from the download -

Whilst there are a number of different methods that can be used to boot GRUB4EFI, this guide focuses on creating a GRUB4EFI bootable USB drive. This method requires firmware USB boot support. Using the bootable USB method is recommended as existing boot files/settings do not need to be edited and the same USB device can be used across multiple computers.

Other methods which are not covered include -

A decision will need to be made about using a single partition or multiple partitioins on the USB drive. As NTFS is not widely supported in UEFI firmware, a FAT32 boot partition with a NTFS data partition is recommended to work around FAT32 file size limitations.

Additional reading -

Ensure that the USB drive has at least one partition formatted with a filesystem supported by the motherboard - FAT32 is recommended as this should be supported globally on systems with UEFI firmware.

Create the following directory structure on the USB device -

Copy the GRUB4EFI \bootx64.efi file to \EFI\boot\bootx64.efi

Copy the GRUB4EFI \bootia32.efi file to \EFI\boot\bootia32.efi

Create a GRUB4EFI configuration file \menu.lst in the path \EFI\grub\menu.lst

The USB device should have a FAT32 partition with the following directory structure (with paths relative to the volume root, directories in red and files in blue) -


menu.lst (configuration file)

The GRUB4EFI configuration file \EFI\grub\menu.lst is a plain text file containing a series of GRUB4EFI commands, similar to a batch script. Commands in menu entries can be entered in the command-line, which is useful during testing or for troubleshooting as verbose feedback is issued following commands.

The GRUB4EFI loader \EFI\boot\bootx64.efi is configured to scan all devices/partitions with a supported filesystem for the configuration file \EFI\grub\menu.lst. If the system has more than one device/partition containing the path+file \EFI\grub\menu.lst then only the first instance found during the scanning process will be loaded - any other files with the same path+name will be ignored.

The root device will be set as the device from which the configuration file \EFI\grub\menu.lst was loaded. This can be problematic if the path+file is on more than one device as you may not be aware which menu you have loaded. You can check which device is root using the command-line. Use the root command. Example with output -

To search for all instances of \EFI\grub\menu.lst use the command find /EFI/grub/menu.lst. Example with output -

GRUB4EFI appears to allocate the device from which the GRUB4EFI boot manager (\EFI\boot\bootx64.efi) is loaded as the highest disk number. As an example, on a system with two physical (hd) type devices the boot device was allocated as (hd1). On a system with four physical devices the boot device was allocated as (hd3)

The order in which devices are searched may also be of interest. On a system with four devices, the search order appears to be -

Example using T470s test system with three USB disks attached. All devices contained multiple partitions with \EFI\boot\menu.lst copied to all partitions. GRUB4EFI was booted from the internal disk which was subsequently allocated as (hd3) -

NOTE - (hd3,3) contained five partitions. (hd3,1) is not listed in the results - this is the MSR partition and did not contain a copy of \EFI\boot\menu.lst.

Document date - 12th April 2023