EFI stub loading of kernel directly from firmware instead of using ELILO or GRUB
by breaker from LinuxQuestions.org on (#6JM41)
Heya, I was recently turned on to the fact that this is possible.
The Gentoo Wiki pointed me in the right direction.
https://wiki.gentoo.org/wiki/EFI_stub
I'm doing this on an old 2011 acer Veriton X2610 that has UEFI firmware.
I just press F12 to boot other OS from the menu, but beware, if I need to boot Windows Server, then I make sure to set a Supervisor password in the BIOS settings so Windows can't override my boot order or screw with anything.
I've booted this system using GRUB(2) and ELILO just fine previously.
For reference (yes, I need to update my kernel):
Code:root@ace:/# inxi
CPU: dual core Intel Pentium G630 (-MCP-) speed/min/max: 1620/1600/2700 MHz
Kernel: 5.15.27 x86_64 Up: 44m Mem: 2704.2/7903.2 MiB (34.2%)
Storage: 298.1 GiB (23.2% used) Procs: 217 Shell: Bash inxi: 3.3.12
root@ace:/# uname -a
Linux ace.local 5.15.27 #1 SMP PREEMPT Tue Mar 8 18:18:11 CST 2022 x86_64 Intel(R) Pentium(R) CPU G630 @ 2.70GHz GenuineIntel GNU/LinuxI'm using LVM on another disk for Slackware apart from the one with GPT and EFI system partition and Windows Server 2012.
Code:root@ace:/boot# lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda LVM2_member LVM2 001 dqCChJ-I02s-r3hR-IXBh-o4ye-LrVb-cfw7S7
ace0-swap swap 1 dd90506d-3f21-42e6-b4d0-30ed3b81197a [SWAP]
ace0-boot ext4 1.0 boot b19b2345-03f7-4602-bff7-165f8567eade 117.7M 41% /boot
ace0-root ext4 1.0 root 6d9a1c9b-3407-4276-914d-fcca0422f9ab 22G 51% /
ace0-home ext4 1.0 home 8ba0252a-ba70-4f75-9fdf-a31378ea6fba 2.3G 90% /home
ace0-temp ext4 1.0 temp 47c054f1-66c1-4ed7-9ced-bde3dd734ccc
sdb
sdb1 ntfs Recovery A01EBA041EB9D40E
sdb2 vfat FAT32 EFI 1ABA-2C7F
sdb3
sdb4 ntfs F21ABC211ABBE0B1
sr0Here are the contents of my EFI System partition and elilo.conf
Code:root@ace:/boot# mount -t vfat /dev/sdb2 /mnt/esp
root@ace:/# ls /mnt/esp/EFI/Slackware
elilo.conf elilo.efi initrd.gz vmlinuz
root@ace:/# cat /mnt/esp/EFI/Slackware/elilo.conf
prompt
timeout=50
default=efi
image=vmlinuz
label=efi
initrd=initrd.gz
read-only
root=/dev/ace0/root
# append="root=/dev/mapper/ace0-root vga=normal ro"I don't normally mount my EFI in fstab, so I mounted under a directory I created named /mnt/esp as you can see above. It does not need to be mounted to create the below UEFI firmware entry. First I unset my BIOS Supervisor password. Next, I created the entry using efibootmgr. Note, the single quotes around the loader option were mandatory, it did not create the correct path without them. See the man page for efibootmgr for details.
Code:root@ace:/# efibootmgr -c -d /dev/sdb -p 2 -L "EFI-stub-Slackware" -l '\EFI\Slackware\vmlinuz' -u 'root=UUID=6d9a1c9b-3407-4276-914d-fcca0422f9ab ro initrd=\EFI\Slackware\initrd.gz'Now my new entry has moved ahead of the old one for ELILO. This output is shown after booting into Slackware with the new entry I just created:
Code:root@ace:/# efibootmgr
BootCurrent: 0005
Timeout: 1 seconds
BootOrder: 0005,0004,0002,0001,0000,0003
Boot0000* UEFI: SATA: HL-DT-ST DVDRAM GH70N BBS(18,,0x0)
Boot0001* UEFI: INTEL SSDSA2M160G2GC PciRoot(0x0)/Pci(0x1f,0x5)/Ata(0,0,0)/HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)
Boot0002* Windows Boot Manager HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................
Boot0003* UEFI: SATA: INTEL SSDSA2M160G2GC BBS(17,,0x0)
Boot0004* Slackware HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Slackware\elilo.efi)
Boot0005* EFI-stub-Slackware HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Slackware\vmlinuz)r.o.o.t.=.U.U.I.D.=.6.d.9.a.1.c.9.b.-.3.4.0.7.-.4.2.7.6.-.9.1.4.d.-.f.c.c.a.0.4.2.2.f.9.a.b. .r.o. .i.n.i.t.r.d.=.\.E.F.I.\.S.l.a.c.k.w.a.r.e.\.i.n.i.t.r.d...g.z.In my creation of the EFI boot entry, note the use of backslashes and where single vs. double quotes were used.
That's all, YMMV.
The Gentoo Wiki pointed me in the right direction.
https://wiki.gentoo.org/wiki/EFI_stub
I'm doing this on an old 2011 acer Veriton X2610 that has UEFI firmware.
I just press F12 to boot other OS from the menu, but beware, if I need to boot Windows Server, then I make sure to set a Supervisor password in the BIOS settings so Windows can't override my boot order or screw with anything.
I've booted this system using GRUB(2) and ELILO just fine previously.
For reference (yes, I need to update my kernel):
Code:root@ace:/# inxi
CPU: dual core Intel Pentium G630 (-MCP-) speed/min/max: 1620/1600/2700 MHz
Kernel: 5.15.27 x86_64 Up: 44m Mem: 2704.2/7903.2 MiB (34.2%)
Storage: 298.1 GiB (23.2% used) Procs: 217 Shell: Bash inxi: 3.3.12
root@ace:/# uname -a
Linux ace.local 5.15.27 #1 SMP PREEMPT Tue Mar 8 18:18:11 CST 2022 x86_64 Intel(R) Pentium(R) CPU G630 @ 2.70GHz GenuineIntel GNU/LinuxI'm using LVM on another disk for Slackware apart from the one with GPT and EFI system partition and Windows Server 2012.
Code:root@ace:/boot# lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda LVM2_member LVM2 001 dqCChJ-I02s-r3hR-IXBh-o4ye-LrVb-cfw7S7
ace0-swap swap 1 dd90506d-3f21-42e6-b4d0-30ed3b81197a [SWAP]
ace0-boot ext4 1.0 boot b19b2345-03f7-4602-bff7-165f8567eade 117.7M 41% /boot
ace0-root ext4 1.0 root 6d9a1c9b-3407-4276-914d-fcca0422f9ab 22G 51% /
ace0-home ext4 1.0 home 8ba0252a-ba70-4f75-9fdf-a31378ea6fba 2.3G 90% /home
ace0-temp ext4 1.0 temp 47c054f1-66c1-4ed7-9ced-bde3dd734ccc
sdb
sdb1 ntfs Recovery A01EBA041EB9D40E
sdb2 vfat FAT32 EFI 1ABA-2C7F
sdb3
sdb4 ntfs F21ABC211ABBE0B1
sr0Here are the contents of my EFI System partition and elilo.conf
Code:root@ace:/boot# mount -t vfat /dev/sdb2 /mnt/esp
root@ace:/# ls /mnt/esp/EFI/Slackware
elilo.conf elilo.efi initrd.gz vmlinuz
root@ace:/# cat /mnt/esp/EFI/Slackware/elilo.conf
prompt
timeout=50
default=efi
image=vmlinuz
label=efi
initrd=initrd.gz
read-only
root=/dev/ace0/root
# append="root=/dev/mapper/ace0-root vga=normal ro"I don't normally mount my EFI in fstab, so I mounted under a directory I created named /mnt/esp as you can see above. It does not need to be mounted to create the below UEFI firmware entry. First I unset my BIOS Supervisor password. Next, I created the entry using efibootmgr. Note, the single quotes around the loader option were mandatory, it did not create the correct path without them. See the man page for efibootmgr for details.
Code:root@ace:/# efibootmgr -c -d /dev/sdb -p 2 -L "EFI-stub-Slackware" -l '\EFI\Slackware\vmlinuz' -u 'root=UUID=6d9a1c9b-3407-4276-914d-fcca0422f9ab ro initrd=\EFI\Slackware\initrd.gz'Now my new entry has moved ahead of the old one for ELILO. This output is shown after booting into Slackware with the new entry I just created:
Code:root@ace:/# efibootmgr
BootCurrent: 0005
Timeout: 1 seconds
BootOrder: 0005,0004,0002,0001,0000,0003
Boot0000* UEFI: SATA: HL-DT-ST DVDRAM GH70N BBS(18,,0x0)
Boot0001* UEFI: INTEL SSDSA2M160G2GC PciRoot(0x0)/Pci(0x1f,0x5)/Ata(0,0,0)/HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)
Boot0002* Windows Boot Manager HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................
Boot0003* UEFI: SATA: INTEL SSDSA2M160G2GC BBS(17,,0x0)
Boot0004* Slackware HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Slackware\elilo.efi)
Boot0005* EFI-stub-Slackware HD(2,GPT,77f037c8-e7e9-4ce2-a1c4-a5d7979daa6f,0x96800,0x31800)/File(\EFI\Slackware\vmlinuz)r.o.o.t.=.U.U.I.D.=.6.d.9.a.1.c.9.b.-.3.4.0.7.-.4.2.7.6.-.9.1.4.d.-.f.c.c.a.0.4.2.2.f.9.a.b. .r.o. .i.n.i.t.r.d.=.\.E.F.I.\.S.l.a.c.k.w.a.r.e.\.i.n.i.t.r.d...g.z.In my creation of the EFI boot entry, note the use of backslashes and where single vs. double quotes were used.
That's all, YMMV.