EFI3M, the EFI Multi-boot Menu Maker

Introduce yourself, create test postings or talk nonsense
DidierSpaier
Posts: 518
Joined: 20. Jun 2016, 20:15

EFI3M, the EFI Multi-boot Menu Maker

Post by DidierSpaier »

EFI3M, the EFI Multi-boot Menu Maker, is available here:
https://github.com/DidierSpaier/EFI3M

This shell script builds a menu with entries for all accessible EFI OS boot loaders at time of running it, that will be presented at next startup, stored in an internal EFI System Partition and/or written on an USB stick, making it a rescue multi-boot media.

How to use it?
1) Download the script EFI3M
2) Make it executable:
chmod 0755 EFI3M
3) Run it as root (use sudo for some distributions):
./EFI3M or "sh EFI3M"

It should work on any Linux distribution with GRUB2 installed (used to build the menu as an EFI application).

This of course includes Salix and Slackel ;)

To help the visually impaired, the boot menu optionally plays a sound at startup, a tune of n sounds when starting the boot entry numbered n from
the top of the menu, and specific tunes for reboot and halt, so they know what they are doing.

To know more, you have the README on GitHub, and a page of information accessible from the main menu of EFI3M when running it.

I have tested EFI3M on Slint64-14.2.1.1, Slackware 14.2, Debian testing, Fedora Workstation 28-1.1, Arch Linux 20180601, openSUSE 15.0 Leap,
Ubuntu Mate 18.04.

I plan to internationalize EFI3M, but as my native language is French I need to first enhance the wording of the dialog in English. I will be grateful for your proposed correction.

Greetings,

Didier
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by mimosa »

This looks great. I am a bit reluctant to test it because I am booting with rEFInd and don't really want to mess with it.

How does this interact in practical terms with elilo, for instance, if you upgrade your Salix kernel, presumably you would still use eliloconfig first? Would you then need to rebuild the multi-boot menu?
DidierSpaier
Posts: 518
Joined: 20. Jun 2016, 20:15

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by DidierSpaier »

mimosa wrote: 18. Jun 2018, 07:56 This looks great. I am a bit reluctant to test it because I am booting with rEFInd and don't really want to mess with it.
That's not an issue at all. rEFInd puts its files in its own directory /EFI/refind/, so does EFI3M in /EFI/efibootmanager.
Additionally if you want EFI3M can put the same files in /EFI/BOOT/ but only if it doesn't already include a BOOTx64.EFI file or a grub.cfg file, unless it was a previous version written by EFI3M itself, which it checks against efibootmenu.md5 and efibootgrub.md5 that it also puts in the same directory.

EDIT. You made me worry if this test

Code: Select all

elif [ ! -f $DEFAULTDIR/BOOTx64.EFI ]
would succeed if the file was named e.g. bootx64.efi or BOOTx64.efi, but fortunately it fails as we are in an EFI partition with a FAT file system, so these names all designate the same file. I just checked.

Long story short, we take care not to fiddle with any alien file.

Anyway if you are still not confident you can begin with putting the menu on an USB stick and boot from it. In this case EFI3M doesn't write anything in an internal ESP.

If you have rEFInd installed when running EFI3M, EFI3M will include a boot entry for rEFInd. And rEFInd will also include a boot entry for the menu written by EFI3M as soon as you restart it. Yes, I invented the recursive booting ;)
However, you can hide any boot entry from the Customization sub-menu of EFI3M , including the one for rEFInd.
mimosa wrote: 18. Jun 2018, 07:56How does this interact in practical terms with elilo, for instance, if you upgrade your Salix kernel, presumably you would still use eliloconfig first?
Yes.
mimosa wrote: 18. Jun 2018, 07:56Would you then need to rebuild the multi-boot menu?
No, because the path to elilo.efi will remain the same, so you will just execute the updated elilo.efi, itself driven by the new elilo.conf.

I take the occasion to thank laprjns aka Rich who helped a lot with preliminary testing.

Best,

Didier
User avatar
laprjns
Salix Warrior
Posts: 1105
Joined: 28. Aug 2009, 01:30
Location: Connecticut USA

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by laprjns »

You're certainly welcome Didier. I enjoyed testing your scripts although I don't have as much time now as I had back a few months ago. EFI3M is a nice tool for grub. Makes updating and changing the grub boot manager much easier. Shouldn't have to worry about losing your rEFInd, just need to use guefi to reorder you boot menu making rEFInd the first boot option.

To be honest thought, I still prefer rEFInd as a boot manager. It does one thing, manages the systems boot options, and in my opinion does it better than any others that I've tried.
“Don’t you see that the whole aim of Newspeak is to narrow the range of thought?"
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by mimosa »

I just successfully created the USB stick. I like the way it will only accept a newly plugged device.

However, it won't boot Salix - I see a peculiar message about the "file" and a long path ending in EndEntire.

One comment, though I don't know how practical it is, but it might be nice to be able to boot another USB, as with rEFInd. Sometimes for some reason such a USB will not boot directly.
DidierSpaier
Posts: 518
Joined: 20. Jun 2016, 20:15

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by DidierSpaier »

mimosa wrote: 19. Jun 2018, 14:02 However, it won't boot Salix - I see a peculiar message about the "file" and a long path ending in EndEntire.
That's weird, indeed.

Please mount the only partition of the USB stick written by EFI3M and attach or paste the content of /mnt/EFI/BOOT/grub.cfg.

Also provide the output of these commands:

Code: Select all

cat /var/efibootmenu
lsblk -l -o name,uuid,type,parttype,size,fstype|grep part

mimosa wrote: 19. Jun 2018, 14:02One comment, though I don't know how practical it is, but it might be nice to be able to boot another USB, as with rEFInd. Sometimes for some reason such a USB will not boot directly.
To try, just comment out lines 473-475 like this:

Code: Select all

#		if [ "$TRANSPORT" = "usb" ] && [ "$HOTPLUG" = "1" ]; then
#			continue
#		fi
That should do the trick.

Caveat: it will work only if the USB stick including the EFI boot loader that you want to include in the menu is already plugged in when you run EFI3M, as it is not able to refresh itself (it's a limitation of GRUB vs rEFInd).
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by mimosa »

Here is the output as requested:

Code: Select all

mimosa[~]$ sudo mount /dev/sdb1 ~/mnt/sdb1
Password: 
mimosa[~]$ cat mnt/sdb1/EFI/BOOT/grub.cfg
# Configuration file written by EFI3M, the EFI Multi-boot Manager Maker.
set timeout=15
play 480 440 1
set menu_color_normal=white/black
set menu_color_highlight=white/blue
menuentry "(sda1)/EFI/Salix-Xfce-14.2/elilo.efi" {
    insmod part_gpt
    insmod part_msdos
    insmod fat
    search --fs-uuid --set=root 9E76-69C7
    chainloader /EFI/Salix-Xfce-14.2/elilo.efi
    play 480 262 2
}
menuentry "Shut down computer" {
play 240 523 3 392 3 330 3 262 3
    halt
}
menuentry "Reboot computer" {
play 240 523 1 392 1 330 1 262 1 330 1 392 1 523 1
    reboot
}
mimosa[~]$ cat /var/efibootmenu
 sda1 9E76-69C7 /EFI/Salix-Xfce-14.2/elilo.efi LABEL=defaultscheme
mimosa[~]$ lsblk -l -o name,uuid,type,parttype,size,fstype|grep part
sda1 9E76-69C7                            part c12a7328-f81f-11d2-ba4b-00a0c93ec93b  265M vfat
sda2 12ca9fbd-08f7-4d9f-ab1b-8c49d8385200 part 0fc63daf-8483-4772-8e79-3d69d8477de4 12.6G btrfs
sda3 100f4041-9767-4eca-abba-6fec9fa29035 part 0fc63daf-8483-4772-8e79-3d69d8477de4 15.1G ext4
sdb1 A4A3-DF4C                            part c12a7328-f81f-11d2-ba4b-00a0c93ec93b    1M vfat
Thanks for the suggestion about including USB devices, I'll give it a try.
DidierSpaier
Posts: 518
Joined: 20. Jun 2016, 20:15

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by DidierSpaier »

The output looks good. Maybe BOOTx64.EFI e was not correctly built (issue with efibootmgt that writes it?)

These commands :

Code: Select all

ls -lh mnt/EFI/BOOT/BOOTx64.EFI
ls -lh /boot/efimultibootmenux64.efi
should give the same size (701K here).

If not (like if you get "file not found, or a size of zero) this is the issue. Theb I need the the exact error message you get. For this please insert this command between the lines 716 (build_boot_loader) and 717 (BADSTICK="n"):

Code: Select all

read -p "Please copy ad paste the whole error message above before pressing Enter" dummy
and run EFI3M again.

I assume you will actually see an error message at this step, which would give a clue.
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by mimosa »

Code: Select all

mimosa[~]$ ls -lh /boot/efimultibootmenux64.efi
-rw-r--r-- 1 root root 664K Jun 19 14:50 /boot/efimultibootmenux64.efi
mimosa[~]$ ls -lh mnt/sdb1/EFI/BOOT/BOOTx64.EFI
-rwxr-xr-x 1 root root 664K Jun 19 14:51 mnt/sdb1/EFI/BOOT/BOOTx64.EFI
mimosa[~]$ cat /boot/efi/EFI/Salix-Xfce-14.2/elilo.conf
chooser=simple
delay=1
timeout=1
#
image=vmlinuz
        label=vmlinuz
        initrd=initrd.gz
        read-only
        append="root=/dev/sda2 vga=normal ro"
mimosa[~]$ ls /boot/efi/EFI/Salix-Xfce-14.2/
elilo.conf  elilo.efi  initrd.gz  vmlinuz
It occurs to me it may be because I deleted some grub stuff (I think) to remove unneeded boot items in rEFInd. Or because I'm booting with an initrd? So I've included some output other than what you requested.

I'm sure it's not relevant but this isn't a multi-boot machine - just Salix for me. :mrgreen:
DidierSpaier
Posts: 518
Joined: 20. Jun 2016, 20:15

Re: EFI3M, the EFI Multi-boot Menu Maker

Post by DidierSpaier »

I any case EFI3M just loads elilo.efi so, if you if you can boot directly Salix, I fail to see why you couldn't boot it from the menu written by EFI3M :?

Is this menu at least displayed when you boot off the USB stick it wrote (assuming the firmware is set to boot on USB, of course)? Then, what happens when you try to boot? And are "Reboot" and "Shutdown" working in this menu?

If you could remember the exact error message you got, this could give a clue.

Meanwhile, I will set up a VM with just Salix-Xfce-14.2 and see if I can reproduce the issue.
Post Reply