From `grub2-efi` to `systemd-boot`

Introduction
I know there are already some threads about the subkject itself, but my situation is slightly different than those, and the appraoch may differ.

Current => future situation
Current

knurpht@Lenovo-P16:~> lsblk -f
NAME        FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1                                                                            
├─nvme0n1p1 vfat   FAT32       3419-10D6                             504,4M     1% /boot/efi
├─nvme0n1p2 btrfs              980a6220-cd3f-4564-aec8-2ef3f375f5e3  202,6G    78% /opt
│                                                                                  /home
│                                                                                  /var
│                                                                                  /usr/local
│                                                                                  /root
│                                                                                  /boot/grub2/x86_64-efi
│                                                                                  /boot/grub2/i386-pc
│                                                                                  /srv
│                                                                                  /.snapshots
│                                                                                  /
└─nvme0n1p3 vfat   FAT32       56B0-AF5F                                           
knurpht@Lenovo-P16:~> 

Future:

knurpht@Lenovo-P16:~> lsblk -f
NAME        FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1                                                                            
├─nvme0n1p1 vfat   FAT32       3419-10D6                             504,4M     1% /
├─nvme0n1p2 btrfs              980a6220-cd3f-4564-aec8-2ef3f375f5e3  202,6G    78% /opt
│                                                                                  /home
│                                                                                  /var
│                                                                                  /usr/local
│                                                                                  /root
│                                                                                  /boot/grub2/x86_64-efi
│                                                                                  /boot/grub2/i386-pc
│                                                                                  /srv
│                                                                                  /.snapshots
│                                                                                  /
└─nvme0n1p3 vfat   FAT32       56B0-AF5F       2GB     /boot/efi       
knurpht@Lenovo-P16:~> 

My simple plan

  • Install systemd-boot and deps
  • mount nvme0n1p3 on /mnt
  • copy everything from the old EFI to the NEW
  • unmount the old EFI, mount the new
  • adapt fstab accordingly
  • run the appropriate update-bootloader commands
  • run dracut -f
  • Reboot

Questions

  • Would this approach work?
  • If no, what is missing or even outright wrong and why?

I am wondering where is your /boot I only see /boot/efi.

For me on Tumbleweed:

> ls -lsa /boot
total 144220
    4 dr-xr-xr-x  5 root root     4096 Apr  9 20:46 .
    0 drwxr-xr-x 20 root root      263 Feb 25 08:26 ..
  296 -rw-r--r--  1 root root   299258 Mar 25 12:00 config-6.19.10-1-default
  296 -rw-r--r--  1 root root   299258 Apr  2 18:41 config-6.19.11-1-default
    4 drwxr-xr-x  5 root root     4096 Jan  1  1970 efi
    4 drwxr-xr-x  6 root root     4096 Apr  7 20:10 grub2
    0 lrwxrwxrwx  1 root root       24 Apr  7 07:54 initrd -> initrd-6.19.11-1-default
46492 -rw-------  1 root root 47606968 Apr  9 20:46 initrd-6.19.10-1-default
46496 -rw-------  1 root root 47608443 Apr  9 20:46 initrd-6.19.11-1-default
   16 drwx------  2 root root    16384 Jun 13  2024 lost+found
    4 -rw-r--r--  1 root root      569 Mar 25 12:00 sysctl.conf-6.19.10-1-default
    4 -rw-r--r--  1 root root      569 Apr  2 18:41 sysctl.conf-6.19.11-1-default
 9000 -rw-r--r--  1 root root  9211948 Mar 25 12:00 System.map-6.19.10-1-default
 9000 -rw-r--r--  1 root root  9212914 Apr  2 18:41 System.map-6.19.11-1-default
    0 lrwxrwxrwx  1 root root       25 Apr  7 07:54 vmlinuz -> vmlinuz-6.19.11-1-default
16296 -rw-r--r--  1 root root 16685424 Mar 25 12:00 vmlinuz-6.19.10-1-default
    4 -rw-r--r--  1 root root       65 Mar 25 12:00 .vmlinuz-6.19.10-1-default.hmac
16300 -rw-r--r--  1 root root 16689520 Apr  2 18:41 vmlinuz-6.19.11-1-default
    4 -rw-r--r--  1 root root       65 Apr  2 18:41 .vmlinuz-6.19.11-1-default.hmac
    0 lrwxrwxrwx  1 root root       31 Apr  7 07:54 .vmlinuz.hmac -> .vmlinuz-6.19.11-1-default.hmac

Here you go:

knurpht@Lenovo-P16:~> ls -lsa /boot
totaal 144476
    0 dr-xr-xr-x 1 root root      712  9 apr 18:37 .
    0 drwxr-xr-x 1 root root      142 26 feb 11:48 ..
    4 lrwxrwxrwx 1 root root       43 30 mrt 15:12 config-6.19.10-1-default -> ../usr/lib/modules/6.19.10-1-default/config
    4 lrwxrwxrwx 1 root root       43  7 apr 04:02 config-6.19.11-1-default -> ../usr/lib/modules/6.19.11-1-default/config
    4 drwxr-xr-x 3 root root     4096  1 jan  1970 efi
    0 drwxr-xr-x 1 root root       98  9 apr 18:37 grub2
    4 lrwxrwxrwx 1 root root       24  7 apr 04:02 initrd -> initrd-6.19.11-1-default
72208 -rw------- 1 root root 73939433  9 apr 18:35 initrd-6.19.10-1-default
72212 -rw------- 1 root root 73943821  9 apr 18:36 initrd-6.19.11-1-default
    4 lrwxrwxrwx 1 root root       48 30 mrt 15:12 sysctl.conf-6.19.10-1-default -> ../usr/lib/modules/6.19.10-1-default/sysctl.conf
    4 lrwxrwxrwx 1 root root       48  7 apr 04:02 sysctl.conf-6.19.11-1-default -> ../usr/lib/modules/6.19.11-1-default/sysctl.conf
    4 lrwxrwxrwx 1 root root       47 30 mrt 15:12 System.map-6.19.10-1-default -> ../usr/lib/modules/6.19.10-1-default/System.map
    4 lrwxrwxrwx 1 root root       47  7 apr 04:02 System.map-6.19.11-1-default -> ../usr/lib/modules/6.19.11-1-default/System.map
    4 lrwxrwxrwx 1 root root       25  7 apr 04:02 vmlinuz -> vmlinuz-6.19.11-1-default
    4 lrwxrwxrwx 1 root root       44 30 mrt 15:12 vmlinuz-6.19.10-1-default -> ../usr/lib/modules/6.19.10-1-default/vmlinuz
    4 lrwxrwxrwx 1 root root       50 30 mrt 15:12 .vmlinuz-6.19.10-1-default.hmac -> ../usr/lib/modules/6.19.10-1-default/.vmlinuz.hmac
    4 lrwxrwxrwx 1 root root       44  7 apr 04:02 vmlinuz-6.19.11-1-default -> ../usr/lib/modules/6.19.11-1-default/vmlinuz
    4 lrwxrwxrwx 1 root root       50  7 apr 04:02 .vmlinuz-6.19.11-1-default.hmac -> ../usr/lib/modules/6.19.11-1-default/.vmlinuz.hmac
    4 lrwxrwxrwx 1 root root       31  7 apr 04:02 .vmlinuz.hmac -> .vmlinuz-6.19.11-1-default.hmac
knurpht@Lenovo-P16:~> 

I think it should work.
In my experience the difficult bit is the update if NVRAM variables in the PC’s firmware, so be careful with messages coming from update-bootloader…
Good luck

1 Like

Can you install systemd-boot if you have grub-bls already?

Nope, see the title, grub2-efi it is.

@knurpht:

Gertjan, a small heads-up found on the ArchWiki – <EFI system partition - Typical mount points>

  • It seems that, there’s a move to have a “/efi” partition rather than “/boot/efi” –
    And, with systemd-boot, an additional “Extended Boot Loader Partition” (XBOOTLDR) below “/boot” is also needed …

Further information here – <UAPI.1 The Boot Loader Specification – Mount Points>
And, here – <systemd – gpt-generator, bootctl, nspawn: EFI mount point handling updates>


For what it’s worth, my current Tumbleweed GRUB2-EFI Desktop system –
(Yesterday, I re-created the EFI partition as FAT32 in place of the ages old FAT16 partition … )

 # lsblk --fs /dev/sda
NAME        FSTYPE FSVER LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                      
├─sda1      vfat   FAT32             E385-55AF                             492,6M     1% /boot/efi
├─sda2      ext4   1.0   System_Root c59a64bf-b464-4ea2-bf3a-d3fd9dded03f     85G    15% /
└─sda3                                                                                   
  └─cr_swap swap   1     cr_swap     18e6fb53-b340-41c8-8660-4988a173f445                [SWAP]
 # 
 # LANG=C parted /dev/sda print
Model: ATA Intenso SSD Sata (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system  Name                  Flags
 1      1049kB  525MB  524MB   fat32        EFI system partition  boot, esp
 2      525MB   118GB  117GB   ext4
 3      118GB   120GB  2148MB                                     swap

 # 
 # LANG=C fdisk -l /dev/sda
Disk /dev/sda: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: Intenso SSD Sata
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 782CEFBA-9790-458F-9159-F55B7969408E

Device         Start       End   Sectors   Size Type
/dev/sda1       2048   1026047   1024000   500M EFI System
/dev/sda2    1026048 230246399 229220352 109.3G Linux filesystem
/dev/sda3  230246400 234441614   4195215     2G Linux swap
 # 

I had the feeling that, the EFI partition had to be the first partition on the disk – for OS compatibility reasons …

  • But I can’t find anything supporting that thought in the Boot Loader specifications – and also not in the GitHub discussion … :roll_eyes:

I don’t need other OS compatibilty, From what I know the EFI partition does not have to be the 1st, but I’m trying to find a method that would utmost require a boot from USB, chroot and undo the changes through fstab and update-bootloader.

I’m beginning to suspect that, simply remounting the existing FAT32 EFI system partition on “/efi” and, mounting “XBOOTLDR” on “/boot” would do the trick with the “systemd-boot” –

  • This ArchWiki text seems to support my suspicion:

Mount the ESP to /efi and additionally mount an “Extended Boot Loader Partition” (XBOOTLDR) to /boot.
This can be useful when a previously created ESP is too small to hold multiple boot loaders and/or kernels but the ESP cannot be easily resized (such as when installing Linux after Windows to dual boot.
This method is supported by at least systemd-boot.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.