UEFI Shell as EFI Stub Bootloader
by Chuck56 from LinuxQuestions.org on (#6P51G)
While use GRUB 2.12 on my desktop running current I noticed that the kernels are bootloaded using the built-in EFI stub. After a little research I tried using a UEFI Shell as a bootloader replacement. My EFI & root partitions are on NVME setup with GPT/VFAT/EXT4. No LVM, RAID, LUKS or alternate OS to complicate the setup.
My UEFI firmware does not have a shell option so I'm using the Tianocore/EDK2 'shellx64.efi' and 'ext2_x64.efi' driver. I used 'efibootmgr' to setup the shell in the firmware. The shell is started as the initial EFI application then in 5 seconds it runs 'startup.nsh' script if found on the EFI partion.
I setup that script to change the video mode, load the ext4 driver from the EFI partition and start a custom 'boot1.nsh' from the ext4 partition. The 'boot1.nsh' file is a kernel command line with append instructions.
The result is kind of 'grub-like' in the fact that the shell, driver and startup script are in the EFI partion with no need to change them or copy any kernel/initrd into the EFI partion. Less chance to corrupt the EFI partion which is set to 'noauto' in fstab.
I do change the 'boot1.nsh' file on the ext4 partition after every kernel update. Previous kernels are still installed and booted with 'boot2.nsh', 'boot3.nsh' and so on. I may automate those 'boot#.nsf' files in the future.
I've used LILO, rEFInd, ELILO, GRUB (2.06 & 2.12) and direct kernel EFI Stub bootloading. Each method has its pros & cons. Learning UEFI Shell and using it's capabilities as a bootloader has been yet another step to help me learn more about the EFI boot process and appreciate the simplicity of using Slackware.
My UEFI firmware does not have a shell option so I'm using the Tianocore/EDK2 'shellx64.efi' and 'ext2_x64.efi' driver. I used 'efibootmgr' to setup the shell in the firmware. The shell is started as the initial EFI application then in 5 seconds it runs 'startup.nsh' script if found on the EFI partion.
I setup that script to change the video mode, load the ext4 driver from the EFI partition and start a custom 'boot1.nsh' from the ext4 partition. The 'boot1.nsh' file is a kernel command line with append instructions.
The result is kind of 'grub-like' in the fact that the shell, driver and startup script are in the EFI partion with no need to change them or copy any kernel/initrd into the EFI partion. Less chance to corrupt the EFI partion which is set to 'noauto' in fstab.
I do change the 'boot1.nsh' file on the ext4 partition after every kernel update. Previous kernels are still installed and booted with 'boot2.nsh', 'boot3.nsh' and so on. I may automate those 'boot#.nsf' files in the future.
I've used LILO, rEFInd, ELILO, GRUB (2.06 & 2.12) and direct kernel EFI Stub bootloading. Each method has its pros & cons. Learning UEFI Shell and using it's capabilities as a bootloader has been yet another step to help me learn more about the EFI boot process and appreciate the simplicity of using Slackware.