Get rid of systemd-boot

Getting rid of systemd-boot

This guide replaces the systemd-boot bootloader, currently used on non-SecureBoot UEFI ZFS installs. It follows from an insight on why it came to be and how Proxmox sets up you with their own installer and partitioning when it comes to two different bootloaders without much explanation.

EFI System Partition

Let’s check what partition(s) belongs to EFI System first: 1

lsblk -o NAME,UUID,PARTTYPENAME
NAME   UUID                                 PARTTYPENAME
sda                                         
|-sda1                                      BIOS boot
|-sda2 9638-3B17                            EFI System
`-sda3 9191707943027690736                  Solaris /usr & Apple ZFS

And mount it: 2

mount /dev/sda2 /boot/efi/

GRUB install

Note

There appears to be a not so clearly documented grub option of the proxmox-boot-tool init command that will likely assist you with what the steps below will demonstrate, however we will rely on standard system tools and aim for opting out from the bespoke tool at the end. For the sake of demonstration and understanding, the steps below are intentionally taken explicitly.

Install overridden GRUB: 3 4

grub-install.real --bootloader-id proxmox --target x86_64-efi --efi-directory /boot/efi/ --boot-directory /boot/efi/ /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
update-grub
Generating grub configuration file ...
W: This system is booted via proxmox-boot-tool:
W: Executing 'update-grub' directly does not update the correct configs!
W: Running: 'proxmox-boot-tool refresh'

Copying and configuring kernels on /dev/disk/by-uuid/9638-3B17
	Copying kernel 6.8.12-4-pve
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.12-4-pve
Found initrd image: /boot/initrd.img-6.8.12-4-pve
Adding boot menu entry for UEFI Firmware Settings ...
done
Found linux image: /boot/vmlinuz-6.8.12-4-pve
Found initrd image: /boot/initrd.img-6.8.12-4-pve
/usr/sbin/grub-probe: error: unknown filesystem.
/usr/sbin/grub-probe: error: unknown filesystem.
Adding boot menu entry for UEFI Firmware Settings ...
done

Verification and clean-up

If all went well, time to delete the leftover systemd-boot entry: 5

efibootmgr -v

Look for the Linux Boot Manager, it is actually quite possible to find a mess of identically named entries here, such as multiple of them, all of which can be deleted if you are intending to get rid of systemd-boot.

BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0004,0002,0000,0003
Boot0000* UiApp	FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331)
Boot0001* proxmox	HD(2,GPT,198e93df-0b62-4819-868b-424f75fe7ca2,0x800,0x100000)/File(\EFI\proxmox\shimx64.efi)
Boot0002* UEFI Misc Device	PciRoot(0x0)/Pci(0x2,0x3)/Pci(0x0,0x0)N.....YM....R,Y.
Boot0003* EFI Internal Shell	FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(7c04a583-9e3e-4f1c-ad65-e05268d0b4d1)
Boot0004* Linux Boot Manager	HD(2,GPT,198e93df-0b62-4819-868b-424f75fe7ca2,0x800,0x100000)/File(\EFI\systemd\systemd-bootx64.efi)

Here it was item 4 and will be removed as the output will confirm:

efibootmgr -b 4 -B
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0002,0000,0003
Boot0000* UiApp
Boot0001* proxmox
Boot0002* UEFI Misc Device
Boot0003* EFI Internal Shell

You can also uninstall the tooling of systemd-boot completely:

apt remove -y systemd-boot

BIOS Boot Partition

Since this is an EFI system, you are also free to remove the superfluous BIOS boot partition, e.g. with the interactive gdisk: 6

gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.9

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Listing all partitions:

Command (? for help): p
Disk /dev/sda: 268435456 sectors, 128.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 58530C23-AF94-46DA-A4D7-8875437A4F18
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 268435422
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34            2047   1007.0 KiB  EF02  
   2            2048         2099199   1024.0 MiB  EF00  
   3         2099200       268435422   127.0 GiB   BF01 

Tip

The code of EF02 corresponds to BIOS boot partition, but its minute size and presence at the beginning of the disk gives itself away as well.

Deleting first and writing changes:

Command (? for help): d

Partition number (1-3): 1

Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Final confirmation:

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

You may now wish to reboot or use partprobe, but it is not essential: 7

apt install -y parted
partprobe

And confirm:

lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0  128G  0 disk 
|-sda2   8:2    0    1G  0 part 
`-sda3   8:3    0  127G  0 part 

And there you have it, a regular GRUB bootloading system which makes use of ZFS on root despite it did not come “out of the box” from the standard installer for historical reasons.