The UEFI GRUB2 (Partition 2) Menu System

For UEFI-booting direct from .ISO, .EFI and other payload files using grub2

The UEFI_GRUB2_PTN2_Beta5.zip free download is now available in the 'Alternate Downloads - Other Files' area.

  Site Map

Introduction

By switching to a special .imgPTN partition image file containing grub2 to the E2B USB drive and booting from it, it is possible to UEFI-boot directly to many linux ISOs and .EFI boot files (such as Memtest and KonBoot EFI files) all from one grub2 menu system (no need to reboot and load a different .imgPTN file each time!). A second primary partition is required on the E2B USB drive which holds the ISOs and other payload files.
 
The main purpose of the GRUB2 menu system, is to allow you to UEFI-boot directly to a menu containing multiple ISOs and .EFI files (even if some are not officially UEFI-bootable!). 
Some ISOs that do not contain any UEFI boot files (\EFI\boot\bootx64.efi and bootia32.efi) will still boot via the grub2 menu system! For instance, the 32-bit Zorin 11 ISO does not contain EFI boot files, yet it can be UEFI-booted direct from the ISO using grub2.
Although you can also MBR-boot from the grub2 menu system, that is not it's main purpose because E2B supports MBR-booting and is much more flexible than the grub2 menu system.
 

Advantages

  • Works best with E2B USB HDDs (fixed-disk type) - but can be used on Removable devices too
  • No need to make files contiguous
  • Can UEFI-boot some linux payloads that do not contain UEFI boot files and cannot normally UEFI-boot (e.g. can boot in all these additional modes: deftz EFI32, kali EFI64, kali light 32 EFI64&EFI32, nst EFI64&EFI32, ophcrack EFI64&EFI32, weakerthan EFI64&EFI32, debian EFI64, fedora EFI64, knoppix EFI64, systemrescuecd EFI32, zorin32 EFI32, avira EFI32, bitdefender EFI32, pwh32 EFI32, drweb EFI64&EFI32)
  • Once you switch to the partition image, you can choose from a wide range of payloads all from one grub2 menu system
  • You can add your own grub2 menu files and payload files without editing any existing .cfg files - just add your own xxxx.grub2 files and they will automatically be added to the menu system
  • The same payload files can be booted from within the E2B grub4dos menu (in MBR-mode)
  • Ideal for linux-based users who do not have access to WinContig or want to use NTFS partitions
  • Comprehensive spreadsheet available of supported payloads
  • Some menus also support persistence
  • Can UEFI-boot (most) payload files (ISOs, etc.) from an NTFS partition
  • Drive can be write-protected (after it is switched to the grub2 .imgPTN file)
  • Can Secure Boot to grub2, but you need to use MokManager
 

Disadvantages

  • You need to have, or create, a second primary partition on your E2B drive
  • Works best with a FAT32 2nd partition, but FAT32 cannot contain files over 4GB
  • If you use an NTFS 2nd partition, then some ISOs will not boot (e.g. Fedora, gentoo, CentOS, BitDefender)
  • Must give each ISO or payload file a special unique name that is recognised by the grub2 menu
  • The .imgPTNLBAa23 partition image file on the E2B partition must be contiguous.
  • Each different payload requires a different and unique .grub2 menu (many menus already provided)
  • If an ISO does not support linux cheat codes for ISO-booting, you will need to extract the files from the ISO
  • Some systems may not allow you to MBR-boot when switched to the 'grub2 menu mode' (no boot option) - this is a BIOS firmware bug. To return to E2B mode, use SWITCH_E2B.exe
  • To boot from the ISOs using the E2B menu, the ISOs need to be made contiguous (use WinContig).
  • You don't get all options of the ISO's full internal boot menu (e.g. live, install, safe mode, memtest, etc.) unless you make your own menus
  • If a linux distro changes it's scripts or kernel, you may need to re-write the .grub2 menu file
  • Not fully compatible with UEFI Secure Boot, you must use MokManager to enroll the hash key into the BIOS firmware first.
 
Excel spreadsheet of over 60 tested/supported payloads - click HERE.
 

Updating an existing E2B GRUB2 drive

If you already have an earlier version of the Grub2 menu system on your E2B drive, here is how to update your E2B USB drive:
 
1. Download the latest UEFI_GRUB2_PTN2_xxx.7z file and extract the files to your Windows system.
2. Copy the UEFI_GRUB2_PTN2_xxxx.imgPTNLBAa23 file to your E2B partition, e.g. \_ISO\MAINMENU\ (delete the older version).
3. Run UPDATE_GRUB2_FILES_ON_USB_DRIVE.cmd from the PTN2 folder in the download folder - this will update your 2nd partition with any changed *.grub2 files.
 

Requirements

 
Download the grub2 Tool Kit and extract the files to a folder on your Windows hard disk.
 
1. Your E2B USB drive must have a second primary partition. These will contain the payload files and the menu structure.
2. You will need the UEFI_GRUB2_PTN2.imgPTNLBAa23 file (included in the download)
3. If you also wish to run the payload files on the 2nd partition from your E2B menu (in MBR mode), you will also need to add some extra E2B grub4dos .mnu files to your E2B USB drive (included in the download).
4. Add your payload files to the 2nd partition (they do not need to be contiguous for the grub2 menu system, but do need to be contiguous for the E2B menu system).
 
Although it is possible to use this scheme with a Removable USB drive, I recommend using a USB Hard Disk as your E2B USB drive.
 
 

Procedure

1. Make a 2nd partition

If your E2B USB drive does not already contain a second partition, then create one using a suitable partition manager (I recommend EaseUS Home Partition Master - free edition, which can add a second partition even to a Removable USB drive). If a small second hidden partition already exists on the E2B USB drive (which it will if you used the E2B script to make it), you should delete it.
 
You can format the new 2nd partition either as FAT32 or NTFS, it needs to be big enough to hold all the ISO files that you want to add...
 
FAT32
  • Most compatible
  • Only allows files below 4GB in size (note a few ISOs are >4GB, e.g. openSUSE-Leap-42.1-DVD-x86_64.iso, blackarchlinux.)
  • If you want to also store backups on this 2nd partition, you will be limited to <4GB files
NTFS
  • Some linux ISOs will not boot from an NTFS drive under grub2 - e.g. Fedora, CentOS, bitdefender and gentoo (see spreadsheet for more).
  • Can have files > 4GB (and thus place large backup files on it and large .iso files)
The volume label of the 2nd partition can be anything you like (e.g. E2B_PTN2).
 
Note: Normally, the first partition of an E2B USB drive will contain your E2B files. However, this grub2 method will still work if your second partition is the one that contains the E2B files.

1.1 Copy the PTN2 files

Once you have made the second partition on your E2B USB drive, you need to copy all the files from inside the 'PTN2' downloaded folder to the root of your second partition. This will give you a folder structure similar to E2B, with \_ISO in the root of the second partition.
 
Note: Windows can only access the first partition on a Removable USB drive. You can swap over PTN1<>PTN2 by using RMPrepUSB - CTRL+O - 2.
Once you have copied over the payload files to partition 2, use RMPrepUSB - CTRL+O - 2 to switch the partitions back again.
 
If done correctly, you should now have a \_ISO\MAINMENU\grub2 folder (and several other new folders) on the second partition.
 
 

2. Add the UEFI_GRUB2_PTN2.imgPTNLBAa23 file

The 'grub2' Tool Kit download will contain a UEFI_GRUB2_PTN2.imgPTNLBAa23 file.
 
As supplied, it will be a (approx. 45MB) partition image file. 
 
Simply copy this to the \_ISO\MAINMENU folder on your E2B USB drive (first partition).
 
You can change the file name if you wish, but keep the .imgPTNLBAa23 file extension (or add 'AUTO' to the end of the extension if you want it to run without the warning prompt).
 
The file must be made contiguous (run WinContig.exe or \MAKE_THIS_DRIVE_CONTIGUOUS.cmd).
 

3. Add the E2B 'PTN2' .mnu files

If you also want to MBR-boot to the payload files on the second parition via the E2B menu system as well as the grub2 menu system, you will need to add the five E2B .mnu files (included in the download) that will enumerate the files on the 2nd partition. E2B (v1.80+) also contains these five .mnu files in the Sample mnu Files folder (the \_ISO\docs\Sample mnu Files\E2B Menus\GRUB2 folder).
 
Copy these five xxxxxPTN2.mnu files to the \_ISO\MAINMENU folder on your E2B partition (or to any menu folder you wish).
 
Note: If the 2nd partition is beyond 137GB on the drive, E2B/grub4dos may not be able to boot from those payloads due to a BIOS bug issue found with some systems, but the grub2 menu system should be able to boot from them.
 

4. Add the payload files to the second partition

You need to add payload files to the second partition and give each payload file a special name (case sensitive).
 
To get started, copy the .iso file to the \_ISO\MAINMENU folder and rename it. An .xls Excel spreadsheet of the required filenames will be present in the download.
 
  • Payload files must be added to the second partition (the first partition disappears when you switch in the .imgPTNLBAa23 file!)
  • The payload filename must be a specific name for it to be recognised by the grub2 menu system. 
    For instance, for the AVG ISO, avg_arl_cdi_all_120_150814a10442.iso, you must rename it to avg.iso
    Nearly all payload file names (and folders) are lowercase (they must match what is used in the .grub2 menu file).
  • Payload files must be copied to the correct folder.
    For instance, avg.iso will only be detected if placed in the \_ISO\MAINMENU or \_ISO\MAINMENU\MNU or \_ISO\LINUX or \_ISO\LINUX\MNU folders.
    There will be a list of what these filenames need to be in the \readme.txt file and .xls spreadsheet.
    For instance, kali.iso can be placed under the MAINMENU folder or the UTILITIES folder, but it will not work if placed under the LINUX folder.
  • Payload files placed in a 'MNU' sub-folder will not be enumerated by the E2B menu system unless you add an E2B .mnu file (but will be enumerated by the GRUB2 menu system).
Tip: Double-click the \FIND_A_STRING_IN_A_GRUB2_MENU.cmd script and enter a search string (e.g. kali). This will then list all lines in the grub2 menu files with the string "kali" in them. This allows you to find out what the filename should be and if a menu is present and what .grub2 file it is in.
Note: If you also want to boot the ISOs from the E2B menu system, you must make them contiguous by running WinContig.
Tip: Copy \MAKE_THIS_DRIVE_CONTIGUOUS.cmd to \ on the 2nd grub2 partition, and also copy the whole \_ISO\docs\WINCONTIG folder to the 2nd partitions \_ISO\docs\WINCONTIG folder. Then you can double-click on the \MAKE_THIS_DRIVE_CONTIGUOUS.cmd script on the 2nd partition to make all files contiguous.
 
 

5. Switch in the .imgPTNLBAa23 file

Finally, you must swap over partitions. Use \_ISO\SWITCH_E2B.exe and double-click on the UEFI_GRUB2_PTN2.imgPTNLBAa23 file.

Or use the E2B menu to select the UEFI_GRUB2_PTN2.imgPTNLBAa23 file.

You should now be able to MBR-boot to the CSM menu and select the grub2 menu system, or directly UEFI-boot to the grub2 menu system.

To restore back the E2B menu system, use \e2b\SWITCH_E2B.exe - Restore E2B partitions (under Windows), or use Menu #0 in the CSM Menu.

 

How it works

The grub2 menu system works by enumerating the .grub2 menu files which are present on the second partition (only specific 'grub2' folders are searched for *.grub2 menu files - see below).
 
These .grub2 files are just grub2 '.cfg style' menu files, which contain grub2 menus. They are the equivalent of the grub4dos .mnu files that are used by grub4dos in the E2B menu system.
 
For instance, if you place 'avg.iso' in the folder \_ISO\ANTIVIRUS\MNU on the second partition, there must be a grub2 menu for it in the \_ISO\ANTIVIRUS\MNU\grub2 folder. In this case, you will find that the antivirus_menu.grub2 file, contains a menu entry for the avg.iso file.
 
Note that some payload files need to be extracted to the \ISO_Extract folder (or other folder).
 
Not all payloads may be listed in the grub2 menu on every system. For instance, if the payload file does not work on 32-bit systems, the menu entry for it will only appear on 64-bit systems. If the payload does not boot in MBR mode, then the menu entry will only be listed when booting in UEFI-mode.
 
Take a look at one of the .grub2 files to see how they work.
 
 

Extracted payloads

Some payloads will not work unless they are extracted  to the 2nd partition. The \_ISO_Extract folder and the \rescue folder are used to hold the extracted files.
 
\ISO_Extract\android-x86  - extract the android ISO into here
\ISO_Extract\phoenix      - make a USB flash drive and then copy the contents of the flash drive to here
\ISO_Extract\remixos      - extract the ISO to here
\ISO_Extract\drweb        - extract casper folder to here. Unpack the casper-rw file for persistence to \ISO_Extract\drweb\casper-rw
\rescue                   - extract the Kaspersky Rescue Disk ISO to the root of the 2nd partition, then move the \boot folder into the \rescue folder (see readme.txt file).
 
For the android based OS's, if you want persistence they will need a data.img file. Read the \ISO_Extract\readme.txt file for instructions on how to make them (e.g. \ISO_Extract\remixos\data.img).
 
Kaspersky AV must be extracted to the root so that we get a \rescue folder (see below).
 
Read the 'readme' files in the \_ISO_Extract folder for more information.
 
IMPORTANT: You will need to copy the correct .grub2 files from the \_ISO\docs\Sample mnu Files folder to the correct menu folder on partition 2. For instance, copy \_ISO\docs\Sample mnu Files\kaspersky_extracted.grub2 to the \_ISO\ANTIVIRUS\grub2 folder - a menu entry for Kaspersky will then appear in the AntiVirus grub2 menu system - if the extracted files are detected.
 
 

Kaspersky AV rescue.iso (extracted)

The Kaspersky rescue.iso must be extracted to the root of partition 2. Then move the \boot folder into the \rescue folder. Instructions are in the \rescue\readme.txt on partition 2 (so you get \rescue\boot).

Copy \_ISO\docs\Sample mnu Files\kaspersky_extracted.grub2 to the \_ISO\ANTIVIRUS\grub2 folder - a menu entry for Kaspersky will then appear in the AntiVirus grub2 menu system - if the extracted files are detected.

Note that you can UEFI-64 boot to Kaspersky even though there are no EFI boot files inside the ISO (EFI32 should also work).

When you run Kaspersky, it will download the updates to a new folder that it will make on the system disk (inside the system you booted with). If you want the updates to be stored on the E2B drive, see the box below.
 
Note: If you wish to run Kaspersky AntiVirus with peristent updates you will need to make a larger .imgPTNLBAa23 file as follows:
 
1.  'Switch' to the UEFI_GRUB2_PTN2.imgPTNLBAa23 partition using  \_ISO\SWITCH_E2B.exe and copy the entire contents to an empty folder 'GRUB2' on your PC's hard drive (don't copy the System Volume Information folder or Recycle Bin folder) . Then switch back to the E2B partition using SWITCH_E2B.exe - Restore E2B Partition(s).
 
2. Drag-and-drop the GRUB2 folder onto the MPI_FAT32 Desktop shortcut - choose a size of 400MB  (must be at least 300MB). Name the file as something suitable, e.g.  UEFI_GRUB2_PTN2_400MB.imgPTNLBAa23. If asked to merge the menu.lst, choose Y or N - it does not matter because we are going to destroy the files in step 4 below!

3. Now copy the new UEFI_GRUB2_PTN2_400MB.imgPTNLBAa23 file to your E2B USB drive's \_ISO\MAINMENU folder and 'switch' to it using \_ISO\SWITCH_E2B.exe. Check that you can now see a 'g2ldr' file in the root of the new partition.

4. IMPORTANT: Now re-copy the entire contents of the original GRUB2 folder to the partition and overwrite all the files (allow enough time for all the files to be copied). This is required because the MPI_FAT32 (MakePartImage) script will have incorrectly modified some of the files. If there is not enough disk space, delete the \boot folder from the new partition (hold down SHIFT+DEL so they are not copied to the Recycle bin on the drive!) and then re-copy all the GRUB2 files again. The contents of the new partition should be identical to the contents of the GRUB2 original folder. Double-check the folder contents carefully and make sure all the files have been copied!

The \Kaspersky Rescue Disk 10.0 folder will be used to store the updates, but make sure that no other disk in the system you are booting on has a folder of the same name in the root of any drive - if it does, then delete the Kaspersky Rescue Disk 10.0 folder from any of the internal hard drives, otherwise the updates may be stored there instead!

Updating your UEFI GRUB2 files with a newer version

If you download a new version of the grub2 menu system, you should replace the old .imgPTNLBAa23 file with the new one.
Then extract/copy/replace the files in the PTN2 folder to the root of your second partition (UPDATE_GRUB2_FILES_ON_USB_DRIVE.cmd is useful for this).
 

Useful GRUB2 Windows scripts

UPDATE_GRUB2_FILES_ON_USB_DRIVE.cmd        - Updates any existing *.grub2 files from the download folder to the USB drive (but only if they already exist on the USB drive)
FIND_A_STRING_IN_A_GRUB2_MENU.cmd          - Looks for a string in all the *.grub2 files
UPDATE_GRUB2_FILES_FROM_MAINMENU.cmd    - The MAINMENU folder contains the 'master' set of grub2 files (see below)
COPY_ALL_GRUB2_FILES_TO_USB_DRIVE.cmd     - Use this to place a default set of .grub2 files on your E2B 2nd partition
 
Note: If you change or edit any .grub2 file, you will need to update all occurrences of it in the other grub2 folders where it is used.
You can use the \UPDATE_GRUB2_FILES_FROM_MAINMENU.cmd script to do this.
It will use the .grub2 files in the \_ISO\MAINMENU\grub2 folder as the 'MASTER SOURCE' and then update any .grub2 files of an identical name in all the other folders. To understand what it does, use T (TEST) so it does not actually alter any files.
This means you just need to edit the .grub2 files in \_ISO\MAINMENU\grub2 and the script will update all other instances of the same file in the other seven folders (if it exists).
 

How to use the GRUB2 menu system

1. First you must switch to the UEFI_GRUB2_PTN2.imgPTNLBAa23 image (by booting to E2B or using SWITCH_E2B.exe).

Note: You can change the name and add 'AUTO' to the file extension - e.g. 'UEFI Grub2 Menu System.imgPTNLBAa23AUTO'. It will immediately switch to the CSM menu.

2. If you MBR-boot, you will see the GRUB2 CSM menu. You can choose the GRUB2 menu entry and boot to the GRUB2 menu in MBR-mode.


  Grub2 CSM menu


  Grub2 MBR-mode menu

 - OR -


From the CSM menu, you can boot via either Clover 32-bit or 64-bit and then select the only option visible to boot to the GRUB2 menu in UEFI-mode.


  Grub2 UEFI-mode menu
 
3. If you reboot the system and select UEFI-booting, then the GRUB2 menu will be immediately loaded in UEFI-mode (shown above).
 
The system supports both 64-bit and 32-bit UEFI booting.
 
Now you can use the GRUB2 menu system to boot to any of the payload files on the second partition.
 
 

Menu Configuration

Simple configuration can be done by editing the defaults.txt file in each grub2 folder (e.g. \_ISO\MAINMENU\grub2\defaults.txt). 
You can set a default entry and timeout for each menu, a console password, beep or play a tune when the menu loads and suppress various menu entries, etc.
Just open the defaults.txt file in Notepad and you can see how to set each value (they are commented out to start with using #).
 
You can also add your own *.grub2 menu files to any of the grub2 folder and then add your own payload files. You can base your menu on the existing  *.grub2 files that are already present.
 

Menu entry order

Grub2 enumerates the .grub2 menu files in a pseudo-random order. It is difficult to change the order in which the menu entries are arranged. If the .grub2 file contains multiple menus, you can re-order the menus text entries inside the file (I recommend that you rename the .grub2 file - otherwise if you update to a later version, it will overwrite your edited file!).
 
 

GRUB2 files and folders explained

Files in the .imgPTN image

The grub2 boot files which cause the system to bot to grub2 are located inside the .imgPTN file in the \boot\grub folder.
 
Initial booting is done via the \EFI\boot files (if booting via UEFI) or via grub4dos and the \g2ldr boot file to start grub2 in MBR-mode.
 
\boot\grub\grub.cfg - this is the first menu config file that is loaded and executed by grub2
\boot\grub\main.cfg - this is the next file to be loaded which displays the Main (first) grub2 menu
\boot\grub\antivirus.cfg, backup.cfg, linux.cfg, utilities.cfg - these are the grub2 sub-menus
\boot\grub\themes\grub2_e2b\*.txt - these control the theme, wallpaper and menu headings for each menu (only the heading is different)
\boot\grub\themes\icons - this folder contains the icons that are displayed to the left of each menu entry. It is specified in a menuentry using the 'class' parameter.
 
 

Files on the 2nd partition

There are two main types of files on the second partition, payload files and .grub2 menu files (and also defaults.txt files).
 
Note that the same .grub2 files (or a sub-set) also copied to the other .\grub2\ folders. For instance backup_menu.grub2 exists in \_ISO\MAINMENU, \_ISO\MAINMENU\MNU, \_ISO\BACKUP and \_ISO\BACKUP\MNU:
 
For example,
 
\_ISO\BACKUP\grub2 folder
=================
backup_menu.grub2
 
So, in this case, only payload files that are referenced in the backup_menu.grub2 file can be detected in the \_ISO\BACKUP folder.
 
The grub2 menu system will enumerate the .grub2 files in each of the grub2 folders on the second partition and add the contents of each .grub2 file into it's own internal menu.
 

The .grub2 menu files

The grub2 menu system enumerates the .grub2 menu files in each menu folder.
You can therefore control what payload files are detected by adding or removing the .grub2 files in these grub2 folders:
 
\_ISO\MAINMENU\grub2
\_ISO\ANTIVIRUS\grub2
\_ISO\BACKUP\grub2
\_ISO\UTILITIES\grub2
\_ISO\LINUX\grub2
 
If you don't want the files to be listed in the E2B menu system, then use the MNU subfolders:
 
\_ISO\MAINMENU\MNU\grub2
\_ISO\ANTIVIRUS\MNU\grub2
\_ISO\BACKUP\MNU\grub2
\_ISO\UTILITIES\MNU\grub2
\_ISO\LINUX\MNU\grub2
 
Currently, the MAINMENU contains all .grub2 files so that you can place any ISO in the MAINMENU folder (or \_ISO\MAINMENU\MNU folder):
 
antivirus_menu.grub2
backup_menu.grub2
linux_menu.grub2
security_menu.grub2
utilities_menu.grub2
 
Note that each menu folder must have a .\grub2 sub-folder, e.g. if you place ISO files in \_ISO\LINUX\MNU folder, then there must be *.grub2 menu files in the \_ISO\LINUX\MNU\grub2 folder.
 
About the xxxx_extracted.grub2 files
Normally, the \_ISO\MAINMENU\grub2 folder contains all the .grub2 menu files, so you can put any ISO in the \_ISO\MAINMENU folder.
 
However, ISOs which need to be extracted have their own .grub2 menu files which are not already present in the menu folders and are stored in the \_ISO\docs\Sample mnu Files folder: e.g.
  • android_x86_extracted.grub2
  • drweb_extracted.grub2
  • kaspersky_extracted.grub2
  • phoenixos_extracted.grub2
  • remixos_extracted.grub2
  • easyre10_extracted.grub2
Copy the correct .grub2 menu file to the menu folder in which you want it to appear (e.g. \_ISO\MAINMENU).
For instance, after you have extracted the phoenix ISO to the correct folder locations, copy the phoenix_extracted.grub2 file to \_ISO\LINUX\grub2 and the phoenix menu entry will appear in the Linux grub2 menu.
If you copied the phoenix_extracted.grub2 file to \_ISO\UTILITIES\grub2 folder, the phoenix menu entry will appear in the Utilities grub2 menu.
 

How to add your own payload files

Let us assume we want to add a new ISO called 'freddy.iso' to the Utilities menu:
 
1. Create a freddy.grub2 (any name will do but it must end in .grub2) which contains the correct grub2 menu text.
2. Place it in the \_ISO\UTILITIES\grub2 folder (for example)
3. Copy the freddy.iso payload file to the \_ISO\UTILITIES folder
 
If you have previously added the E2B .mnu files (Step 3 above), then freddy.iso will automatically appear in the Utilities PTN2 menu in E2B.
 
Note: If you don't want freddy.iso to appear in the E2B Utilities PTN2 menu (perhaps you have a .mnu file for it?), then move both files to the MNU sub-folder, i.e.
\_ISO\UTILITIES\MNU\grub2\freddy.grub2
\_ISO\UTILITIES\MNU\freddy.iso

For E2B menu support, you will also need to create a .mnu file which calls QRUN.g4b if you want to run the ISO from the E2B menu system.
 

Changing the background or menu layout

The grub2 menu system uses a 'Theme' located inside the .imgPTNLBAa23 partition image at \boot\grub\themes\grub2_e2b\theme*.txt. The background jpeg file is specified in these files as well as other settings which you can change. Note that there are 5 files, one for each menu.
 
Many grub2 themes are available on the internet. You can specify which theme to load in the \boot\grub\main.cfg file. Then add the 5 theme*.txt files to your new theme folder and edit them as required (only the title is different in each of the five files).
 

Speeding up the Main grub2 menu

Note that the MAINMENU grub2 folders contain all the .grub2 menu files. This means that you can place a known payload file, such as avg.iso, into the \_ISO\MAINMENU folder and it will be added to the Main GRUB2 menu. However, adding lots of ISOs to the MAINMENU folder and enumerating all the .grub2 files, may cause the Main menu to load slowly.
 
You can speed it up by removing any of the  .grub2 files that you don't need.
 
For instance, if you are not going to put any AntiVirus ISOs into the Main menu, then you can delete the \_ISO\MAINMENU\grub2\antivirus_menu.grub2 and \_ISO\MAINMENU\MNU\grub2\antivirus_menu.grub2 files. 
 
 

Making your own .grub2 menu file

Use one of the menu entries in the existing .grub2 files for reference, e.g. 
 
#$isofpath           e.g. (hd0,msdos2)/_ISO/LINUX - use only in  if [ -e  tests
#$root2              e.g. (hd0,msdos2)  partition containing payload files
#$root               e.g. hd0,msdos1    boot partition with grub2 on it
#$root2uuid          e.g. 1234-2123-33  (uuid of $root2)
 
#Special variables: MBR EFI MBR32 MBR64 EFI32 EFI64 BIT32 BIT64    FAT (true if filesystem on ptn2 is FAT)
#Examples:
#if $BIT32 ; then echo 32-bit ; fi
#if ! $BIT64 ; then echo not 64-bit ; fi
#if [ $BIT64 = true and $FAT = true ] ; then echo 64-bit MBR on FAT partititon ; fi
#if [ $BIT64 = true and $EFI = true ] ; then echo 64-bit EFI (same as \$EFI64) ; fi
 
#CHECK_MNU_FOLDER sets these variables on return
#$ip e.g. /_ISO/LINUX
#$ifp                e.g. (hd0,msdos2)/_ISO/LINUX
#$isofile            e.g. /_ISO/LINUX/xxxx.iso 
 
 
if $EFI; then
if [ -e "$isofpath/new.iso" ]; then
menuentry "New Rescue live CD" --unrestricted --class avira{
   set isoname=new.iso ; CHECK_MNU_FOLDER
    set gfxpayload=keep
    set root=$root2
    loopback loop $isofilename 
    linux (loop)/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=$isofilename quiet splash --
    initrd (loop)/casper/initrd.lz
    boot
}
fi
fi

 

  • The first line (if $EFI; then) tests the current environment, you can choose from $MBR $EFI $BIT64 $BIT32 $EFI32 $EFI64 $MBR32 $MBR64 or $FAT (they can be 'true' or 'false'). This prevents the menu entry from being displayed if it is known that it does not work. For instance, if it only works when booted on UEFI 64-bit systems, use $EFI64. If the payload works on both 32-bit MBR and 32-bit UEFI systems, use $BIT32. If the payload works only in MBR mode, use $MBR. Use $FAT if it only works in FAT partitions. Each 'if' statement must be balanced with a corresponding 'fi' statement.
  • The 2nd line checks for the existence (-e) of the file. The menu entry will not be shown if this test fails.
  • The menuentry line displays the menu entry text, --unrestricted is the security (password) category and should always be used.
    The --class parameter defines which icon  to use. You can also add a --hotkey entry to this line if you want a hotkey (e.g. --hotkey f5 or --hotkey ctrl+g or --hotkey G).
  • The next line defines the name of the payload file and calls the CHECK_MNU_FOLDER function.
    The CHECK_MNU_FOLDER function sets up the following variables with the correct path:
        $ip - path to the payload file - e.g. /_ISO/MAINMENU/MNU
        $ifp - full path with device name - e.g. (hd0,msdos2)/_ISO.MAINMENU/MNU
        $isofilename - the path+filename - e.g /_ISO/MAINMENU/MNU/new.iso
        Note: Do NOT use  $isofpath inside a menuentry - it may contain the incorrect path!
  • The next lines will depend on your payload file:
  •   set root=$root2    - sets the root to the 2nd partition
  •   loopback loop $isofilename - mounts the payload as a loop device
  •   linux (loop)/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=$isofilename quiet splash --
  •   initrd (loop)/casper/initrd.lz
  •   boot - always end the menu with this command. If you omit it, you may get a 'press a key to continue' message.
 

Testing your .grub2 menu

Always test in a MNU\grub2 folder, e.g. \_ISO\MAINMENU\MNU\grub2 (because this is the 'worst case' test - it may work in the main menu folder but not in a MNU sub-folder).
See the FAQ #2 for tips on debugging your new .grub2 menu.
 
Many developers will describe a grub2 menu which some people can get to work but others cannot. This is usually due to different test circumstances.
Some payloads or menus may not work if they boot on a 32-bit UEFI system (or vice versa). Some payloads (e.g. Fedora, gentoo and CentOS) do not boot if the ISO is on an NTFS partition. Also a slightly different version of the ISO may give different results!
 
You will need to test in four modes and using two different partition types - i.e. 8 different test scenarios!
Test each mode using a FAT32 partition 2, and then re-test using an NTFS partition 2.
 
  1. FAT32 - MBR32
  2. FAT32 - MBR64
  3. FAT32 - EFI32
  4. FAT32 - EFI64
  5. NTFS   - MBR32
  6. NTFS   - MBR64
  7. NTFS   - EFI32
  8. NTFS   - EFI64

Depending on the results, you can add in the correct test 'if' line (e.g. if $EFI64; then) to the menu text so that the user is not presented with a menu item that will not work.

 

Grub2 FAQs

Q1. Why don't you just have one FAT32 partition containing E2B with both the E2B grub4dos and the grub2 menu system?
A1. First, that would limit E2B to 4GB files. Secondly, many UEFI-systems will NOT MBR-BOOT from a FAT drive than contains E2B boot files - so it will never boot to the E2B menu. By using a 2nd partition for the payload files, the E2B drive should always MBR-boot (when in normal E2B mode). Also, it allows us to use >4GB files and have an NTFS partition.
 
Q2. I have added\edited a .grub2 file but it is not working properly - how can I find out what is wrong?
A2. Edit the \_ISO\MAINMENU\grub2\defaults.txt file and set the value of the showdelay parameter to 10.
set showdelay=10
Now you can see any errors which may be reported before the menu is displayed.
If there is an error inside the menuentry, then you can debug the file (e.g. \_ISO\MAINMENU\grub\antivirus_menu.grub2) by adding 'echo' and 'read' statements - e.g.
echo here is a ; read
(some code here)
echo here is b ; read
(some more code here)
When you run the menu entry, you will see where the error message occurs and thus know which line is causing it. The 'read' statement will make grub2 wait for you to press the ENTER key.
If you find many menu entries are missing, it often indicates a missing 'fi' line (unbalanced 'if' and 'fi' lines) or bad syntax.
 
Q3. I added fedora-workstation.iso/centos.iso/gentoo.iso to the \_ISO\LINUX folder, but it does not appear in the Linux menu - why?
A3. It needs to be on a FAT32 partition, not an NTFS partition.
 

Q4. I added a payload file to one of the menu folders, but it does not appear in the menu - why?
A4. Check the following:

  • Check it is on the second partition and in the correct folder (e.g. \_ISO\MAINMENU)
  • Check the file name and case is correct - e.g. avg.iso not Avg.iso or AVG.iso or avg.ISO
  • Check it works under your environment - e.g. a 64-bit ISO may not be listed on a 32-bit system or it may not be listed on a UEFI system if it is known not to work under UEFI.
  • Check that it works on the type of partition (FAT32 or NTFS) that it is on (see FAQ Q3 above).
  • Check for syntax errors in the .grub2 menu (see Q2).
Q5. I added an ISO and renamed it as in the Excel spreadsheet and it appears in the menu, but when I run it, linux complains that it cannot find the file - why?
A5. Check the case of the filename of the ISO file. Most filenames and extension should be all lowercase (e.g. use avg.iso, not Avg.iso or AVG.ISO or avg.ISO, etc.). Do not use spaces in the name.
 
Q6. BitDefender is not listed in the menu, or it gives a "invalid loop location: /rescue/livecd.squashfs" error.
A6. It only works if the ISO is on a FAT32 volume. BitDefender won't boot from NTFS (using grub2). Bug in Beta3 .grub2 menu file so it is listed in menu when it shouldn't be if on an NTFS volume!
 
Q7. Kali-light32 (or kali-light.iso) is not listed in the menu.
A7. There is a bug in Beta3. If the CPU is 64-bit, then name it kali-light.iso, if the CPU is a 32-bit CPU, name it kali-light32.iso. In Beta4, 32-bit kali can be named kali32.iso or kali-light32.iso and runs on both 32-bit and 64-bit CPUs.
 
Q8. Only the MemTest86 is listed in the grub2 menu - no .iso files are listed - why?
A8. Check that you do not have any other FAT32 USB drive connected (if using a Zalman\IODD, do not load the WinHelper RMD file or any other disk file). Secure Boot should be disabled in the BIOS\Firmware menu.
 
Q9. Some systems Boot Selection menus do not list a UEFI-boot entry so I cannot UEFI-boot it, but other systems do and it boots OK - why?
If you are sure that you have enabled the UEFI-boot options correctly in the BIOS (e.g. non-Microsoft UEFI OS, etc.), then check the partitions on your E2B USB drive using RMPrepUSB - Drive Info - 0  to examine the partition table. There should be a FAT32 partition and an NTFS partition followed by two empty partition entries. If you have an entry at #3 position (e.g. Type 0x83 ID), this may stop some BIOSes from listing the USB drive as UEFI-bootable. If the #3 partition is not wanted, delete it using a partition editor.
 

How it works

The grub2 menu system works by enumerating the .grub2 menu files which are present on the second partition (only specific 'grub2' folders are searched - see below).
 
These .grub2 files are just grub2 '.cfg style' menu files, which contain grub2 menus. They are the equivalent of the grub4dos .mnu files that are used by grub4dos in the E2B menu system.
 
For instance, if you place 'avg.iso' in the folder \_ISO\ANTIVIRUS\MNU on the second partition, there must be a grub2 menu for it in the \_ISO\ANTIVIRUS\MNU\grub2 folder. In this case, you will find that the antivirus_menu.grub2 file, contains a menu entry for the avg.iso file.
 
Note that some payload files need to be extracted to the \ISO_Extract folder (or other folder).
 
Not all payloads may be listed in the grub2 menu on every system. For instance, if the payload file does not work on 32-bit systems, the menu entry for it will only appear on 64-bit systems. If the payload does not boot in MBR mode, then the menu entry will only be listed when booting in UEFI-mode.

 

Search