Thursday, 9 January 2020

a1ive's grub2 File Manager v1.2

Here is today's version of a1ive's latest grub2 file manager .imgPTN file.

We now have the ability to add our own grub2 menus by adding a .grubfm file which has exactly the same file name as the ISO file.

e.g.


Here we have a .grubfm menu file for the manjaro iso (download link).

The contents of the user-added .grubfm file are:

manjaro xfce-18.0.1-stable-x86_64.grubfm

# available variables are:
# grubfm_file
# grubfm_path
# grubfm_dir
# grubfm_device
# grubfm_disk
# grubfm_name
# grubfm_filename
# grubfm_fileext
# grub_platform=efi or pc  (UEFI or Legacy BIOS)
# grub_cpu=i386 or x86_64 (i386=Legacy mode or 32-bit UEFI, x86_64=UEFI64)
# grub_uefi_version  (e.g. 2.4)
# grub_secureboot
# CPU  (=32 or 64)

if cpuid -l; then set CPU=64; else set CPU=32; fi

# Examples:
# for 64-bit UEFI only:
# if [ "$grub_cpu" == "x86_64" -a "$grub_platform"=="efi" ] ; then
# for 32-bit Legacy
#if [ "$grub_cpu" == "i386" -a "$CPU"=="32" ] ; then

# --class=   defines the icon displayed next to the menuentry

# Only show menu if 64-bit CPU:
if [ "$CPU" == "64" ] ; then
menuentry "Boot: Manjaro.x86_64 xfce " --class=manjaro {
partnew --type=0x00 --file="${grubfm_file}" (${grubfm_disk}) 4
loopback loop "${grubfm_file}" 
set root=(loop)
linux /boot/vmlinuz-x86_64 lang=en_US keytable=us tz=UTC driver=free nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 misobasedir=manjaro misolabel=MJRO1801 systemd.show_status=1
initrd /boot/amd_ucode.img /boot/intel_ucode.img /boot/initramfs-x86_64.img
}
else
# return back to 'open' menu
grubfm_open "${grubfm_file}"
fi

menuentry "Back" {
grubfm_open "${grubfm_file}"

}
This allows us to boot the ISO in any way we want, e.g. change the language\keyboard\country, etc.
It should even be possible to add a persistence ext3/4 file and boot some ISOs with persistence.

Note: It is best to avoid spaces in paths and filenames when dealing with Linux ISOs because the Linux kernel parameter passing mechanism cannot cope with spaces!

This works in both 64-bit MBR and UEFI mode. When you select the .iso file, a new menu entry is added to the 'open' file menu named:  'ISO user menu' which loads your own grubfm menu file:

'open' file menu shows a ISO user menu entry if a .grubfm file is present

This will run your menu


Each menuentry can be assigned an icon, e.g. --class=manjaro, you can choose from these icons:

.grubfm files must have the same file name as the .ISO file which is in the same folder, however .CFG files can be added instead of .grubfm files. These .CFG files can have any file name, but you will need to hard-code the name of the payload file that you want it to use inside the menu. For example, you could have a \CFG folder which just contains lots of .cfg files. The .cfg files can contain grub2 menu entries for all of your payloads which you can keep in the \_ISO\xxxxx folders.


No comments:

Post a comment