The UEFI GRUB2 (Partition 2) Menu System
For UEFI-booting direct from .ISO, .EFI and other payload files using grub2
The UEFI_GRUB2_PTN2_Beta8.zip free download is now available in the 'Alternate Downloads - Other Files' area.
Note: Beta6 had a bug and would not create menu entries for 64-bit payloads!
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.
- 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
- 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 and select Secure Boot-enabled payloads
- ISO filenames must not contain spaces.
- 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 (provided) 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 or linux defrag utility).
- 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. (If you use .imgPTN files, they are fully secure-boot compatible).
Updating an existing E2B GRUB2 drive
How to add the E2B Grub2 Menu system to your E2B drive
1. Make a 2nd partition
- 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
- 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)
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
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.
2. Add the UEFI_GRUB2_PTN2.imgPTNLBAa23 file
3. Add the E2B 'PTN2' .mnu files
4. Add the payload files to the second partition
- 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.
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
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).
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
Useful GRUB2 Windows scripts
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
Default menu (GRUB2 MBR-mode menu)
Theme option with USETHEME set in defaults.txt file (Grub2 MBR-mode menu)
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.
Theme option with USETHEME set in defaults.txt file (Grub2 UEFI-mode menu)
Menu entry order
Alternativley, if you use color_normal=gray/black and a wallpaper with the same grey backround colour, you can effectively hide the menu header and footer text. This greyE2B.jpg can be used or modified as you wish.
GRUB2 files and folders explained
Files in the .imgPTN image
Files on the 2nd partition
The .grub2 menu files
You can therefore control what payload files are detected by adding or removing the .grub2 files in these grub2 folders:
About the xxxx_extracted.grub2 files
Tip: You can test load a background image by pressing c in the grub2 menu to get to the grub2 console and type background_image (hd0,msdos2)/_ISO/myimg.png.
How to add your own payload files
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.
Making your own .grub2 menu file
- 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.
loopback --delete loop
Testing your .grub2 menu
- FAT32 - MBR32
- FAT32 - MBR64
- FAT32 - EFI32
- FAT32 - EFI64
- NTFS - MBR32
- NTFS - MBR64
- NTFS - EFI32
- 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.
Changing the theme background or menu layout
Speeding up the Main grub2 menu
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).
How it works
Q10. I made a copy of your .grub2 menu for my own linux ISO, but I get a 'no medium found'\'squashfs' error - why? - Check that there are no spaces in the path or filename of your ISO.
To support this site, please disable AdBlock for this domain.
Recommended for Easy2Boot - SanDisk Extreme SDCZ80-064G-G46
BitCoin also accepted.