GRUB/Chainloading

Article description::GRUB2 was designed with an improved chainload mode when compared to GRUB Legacy.

Another grub.cfg
It is possible to load a grub configuration file from another filesystem, using the UUID of that filesystem as it is visible from.

ISO images
The new ISO (or loop) chainload mechanism makes chainloading a breeze. It is possible to chainload ISO images (LiveCD/DVDs) with GRUB Legacy, however there exists no way to pass kernel cmdline arguments before boot. In any case, the ISO images in question should be built keeping kernel cmdline arguments in mind.

Without kernel cmdline options, booting ISO images with GRUB2 will fail in the physical media check/test stage of the ISOs boot process. Gentoo liveCD is handy because it has a minimal shell which lets the user mount the squashed image to the correct location and then press the key to continue the boot process. This makes it possible to have a handy way to install an operating system with everything in RAM, especially for "light weight" LiveCDs. No more need to listen to a whining CD/DVD drive on each new command!

To chainload an ISO with custom or default kernel command line arguments, an entry similar to the following can be added to GRUB2's file:

For a permanent and automatic entry to GRUB2's file, a custom script could be added to the  script location:

Do not forget to make the script executable:

Finally regenerate GRUB2's file using  command.

Another bootloader
Chainloading another bootloader to GRUB2 is fairly easy.

Something as simple as the following example is enough to boot another disk that uses a "Custom Super Bootloader":

TrueCrypt
Chainloading the TrueCrypt bootloader on a separate disk is relatively simple and can be done in GRUB2 like any other bootloader:

Chainloading a disk with TrueCrypt in the MBR or a rescue CD image located in encrypted partitions is not possible with GRUB2 (see ). Use either GRUB Legacy or GRUB4DOS as workaround. GRUB4DOS has an interface very similar to GRUB Legacy and a entry which can be used to chainload the TrueCrypt bootloader or to boot a rescue CD (from an encrypted partition on the same disk).

Another workaround is to boot from TrueCrypt as the main boot loader and then hit the to chainload the following partition (if one exists) or the following disk. Then have GRUB2 installed on the partition instead of in the MBR itself so that GRUB2 is chainloaded.

Windows (MSDOS based boot loaders)
When Windows (or another MS DOS based boot loader) is installed on another disk, then regular chainloading in the may be sufficient to boot it. However, if Windows is on the same disk on a different partition, or if regular chainloading doesn't work, then read on.

Microsoft Windows 8 (and above versions) are no longer installed using MSDOS partitions by default, however they do maintain backwards compatibility with BIOS MBR systems. In order to specify Windows 8 (and above) to use MSDOS partitioning the Windows installation DVD needs to be booted in BIOS mode (a non-UEFI boot mode) in order for Windows to install into MSDOS partitions. Manually create a MSDOS partition layout, then manually boot the Windows DVD using a BIOS option in the boot menu list. Sometimes it is necessary in the BIOS firmware configuration tool to disable UEFI mode completely in order to force BIOS MBR mode.

The simplest way to dual boot Windows (or MS-DOS) is to add an MBR menu entry to GRUB2's file for each Windows operating system installed.

For instance, to boot Windows 7, add the following to the file:

A Windows XP example:

Instead of using GRUB2's device syntax, the UUID of the partition containing the Windows bootloader can be used like so:

Partition UUIDs can be obtained with.

An entry for a GPT hybrid MBR works a bit different than the previous BIOS-MBR examples. Booting multiple versions of Windows can be achieved with remapping and/or hiding partitions with GRUB2's  option:

Remapping the devices to set the primary boot disk to other disks can be achieved by using the  option like so:

Probing
GRUB2 is capable of automatically finding Windows partitions and assigning the root partitions. The Windows partition must first be mounted before the probe will be successful. See notes at the end of this section concerning missing and  files and folders; it is wise to make sure these folders do exist before trying to boot Windows using GRUB2.

GRUB2's probing feature requires the package which is not initially pulled in when installing GRUB2.

From the output provided by the above two commands, the  line within GRUB2's  file (below) can be constructed. Remapping the drive and partition as the first hard drive and first partition will make Windows XP or Windows 8 more free of silent errors while loading.

Seeing a boot error message concerning a missing file after attempting to boot one of the previously mentioned  entries is the indication the  folder is missing. This happens when using Windows 8 since the folder does not seem to be generated by default.

Dual-booting Windows on UEFI with GPT
In the case the Windows bootloader was overwritten with GRUB2 or if doesn't do the trick, a UEFI dual boot could be achieved using the following menu entry: