msekletar / systemd-boot

Simple UEFI Boot Manager
GNU Lesser General Public License v2.1
15 stars 14 forks source link

systemd-boot Fails on Multiboot Linux System #1

Open ebsf1 opened 2 years ago

ebsf1 commented 2 years ago

Sadly, the only consequence of installing and configuring systemd-boot on a machine in a multiboot Linux configuration is that it boots to the GRUB shell, i.e.,

grub>

Exiting the GRUB shell takes one to yet another GRUB shell. Exiting those in succession eventually returns the message (capitalization and spacing as in the original):

StartImage failed: Load Error

which leaves the system unresponsive to keyboard input, including Ctrl+Alt+Del. The only recovery is from a hard system reset or power cycle.

In previous iterations of configuration (I've been through dozens over the past eight days), exiting the initial GRUB shell would take one to the systemd-boot menu, albeit with none of its configured boot entries. The only menu entries were for the default Linux boot loader and system firmware, and often only the latter.

A brief synopsis of the configuration:

There is one volume, /dev/sda. For reference, this becomes /dev/sdb when backup media is installed. It hasn't been during this process, and so isn't relevant to this problem, but this must be anticipated.

The ESP is /dev/sda1. It is mounted to /boot/efi via fstab:

UUID=D69D-D8D4 /boot/efi vfat umask=0077 0 1

A variety of Linux versions and flavors in various stages of configuration are installed on /dev/sda2-7. Swap is on /dev/sda8 and data are on /dev/sda9.

The boot manager / loader heretofore has been GRUB2. The reason to switch to systemd-boot is competition among the systems for control of the boot loader.

tree -pugsDF returns:

[drwx------ root     root            4096 Dec 31  1969]  /boot/efi/
├── [drwx------ root     root            4096 Jun 13 07:43]  4fa9a5bf4498415ead7dea7c2724e90a/
├── [drwx------ root     root            4096 Jun 13 07:43]  EFI/
│   ├── [drwx------ root     root            4096 Jun 18 07:05]  BOOT/
│   │   ├── [-rwx------ root     root          955656 Jun 17 22:25]  BOOTX64.EFI*
│   │   ├── [-rwx------ root     root           85672 Jun 17 22:25]  fbx64.efi*
│   │   └── [-rwx------ root     root          856232 Jun 17 22:25]  mmx64.efi*
│   ├── [drwx------ root     root            4096 Jun  9 16:41]  debian/
│   │   ├── [-rwx------ root     root             108 Jun  9 20:35]  BOOTX64.CSV*
│   │   ├── [-rwx------ root     root             126 Jun  9 20:35]  grub.cfg*
│   │   ├── [-rwx------ root     root         1742728 Jun  9 20:35]  grubx64.efi*
│   │   ├── [-rwx------ root     root          856232 Jun  9 20:35]  mmx64.efi*
│   │   └── [-rwx------ root     root          955656 Jun  9 20:35]  shimx64.efi*
│   ├── [drwx------ root     root            4096 Jun 13 07:43]  Linux/
│   ├── [drwx------ root     root            4096 Jun 16 01:30]  systemd/
│   │   └── [-rwx------ root     root           97444 Apr 21 05:14]  systemd-bootx64.efi*
│   └── [drwx------ root     root            4096 Mar 27 22:44]  ubuntu/
│       ├── [-rwx------ root     root             108 Jun 17 22:25]  BOOTX64.CSV*
│       ├── [-rwx------ root     root             126 Jun 17 22:25]  grub.cfg*
│       ├── [-rwx------ root     root         1742728 Jun 17 22:25]  grubx64.efi*
│       ├── [-rwx------ root     root          856232 Jun 17 22:25]  mmx64.efi*
│       └── [-rwx------ root     root          955656 Jun 17 22:25]  shimx64.efi*
└── [drwx------ root     root            4096 Jun 17 21:53]  loader/
    ├── [drwx------ root     root            4096 Jun 17 22:12]  entries/
    │   ├── [-rwx------ root     root             450 Jun 17 22:11]  sdx2.conf*
    │   ├── [-rwx------ root     root             348 Jun 17 21:54]  sdx4.conf*
    │   └── [-rwx------ root     root             384 Jun 17 21:55]  sdx7.conf*
    ├── [-rwx------ root     root             302 Jun 17 07:59]  loader.conf*
    └── [-rwx------ root     root             512 Jun 13 07:43]  random-seed*

A comparison of file dates and times tells me that bootctl install failed to write systemd-bootx64.efi to anywhere but /EFI/systemd/.

Also, note that additions and deletions to boot entries by efibootmgr selectively fail to persist over reboot, especially if the motherboard firmware utility is accessed.

loader.conf is:

#       /boot/efi/loader/loader.conf
#       systemd-boot configuration file

timeout 5
#default 4fa9a5bf4498415ead7dea7c2724e90a-*
#       From man loader.conf, Options, default, at https://www.freedesktop.org/software/systemd/man/loader.conf.html:
#default @saved
default sdx4.conf
console-mode keep
#console-mode max

The files in /EFI/loader/entries are in the form of:

#       /boot/efi/loader/entries/sdx4.conf
#       Boot entry configuration file.

title sdx4 - Ubuntu Desktop 22.04
#linux /boot/vmlinuz            #       "bootctl status" returns "(No such file or directory)"
#linux /vmlinuz                 #       "bootctl status" returns "(No such file or directory)"
#       Preserves symlinks in /boot to current and old kernel, facilitating update; ESP/FAT32 doesn't support symlinks:
#       -       May throw error "StartImage failed: Load Error"
linux ../vmlinuz
#initrd /boot/initrd.img        #       "bootctl status" returns "(No such file or directory)"
#initrd /initrd.img             #       "bootctl status" returns "(No such file or directory)"
#       Preserves symlinks in /boot to current and old initramfs, facilitating update; ESP/FAT32 doesn't support symlinks:
initrd ../initrd.img
#       PARTUUID= and UUID= are equally ineffective, as is quoting:
#options root=UUID=4d6127d3-5763-4c64-bcbe-d71600191d80 rw
options root="PARTUUID=9d1de6a4-452c-42d2-bf18-acee90032326" rw

bootctl status returns:

System:
     Firmware: n/a (n/a)
  Secure Boot: disabled
   Setup Mode: user
 TPM2 Support: no
 Boot into FW: supported

Current Boot Loader:
      Product: n/a
     Features: ✗ Boot counting
               ✗ Menu timeout control
               ✗ One-shot menu timeout control
               ✗ Default entry control
               ✗ One-shot entry control
               ✗ Support for XBOOTLDR partition
               ✗ Support for passing random seed to OS
               ✗ Boot loader sets ESP information
          ESP: n/a
         File: └─n/a

Random Seed:
 Passed to OS: no
 System Token: set
       Exists: yes

Available Boot Loaders on ESP:
          ESP: /boot/efi (/dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7)
         File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot 249.11-0ubuntu3.1)
         File: └─/EFI/BOOT/BOOTX64.EFI

Boot Loaders Listed in EFI Variables:
        Title: ubuntu
           ID: 0x0002
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─/EFI/debian/shimx64.efi

        Title: ubuntu
           ID: 0x0000
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─/EFI/ubuntu/shimx64.efi

        Title: UEFI OS
           ID: 0x0005
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─/EFI/BOOT/BOOTX64.EFI

        Title: Debian GRUB
           ID: 0x0003
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─/EFI/debian/grubx64.efi

        Title: Linux Boot Manager
           ID: 0x0001
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─/EFI/systemd/systemd-bootx64.efi

        Title: ubuntu
           ID: 0x0006
       Status: active, boot-order
    Partition: /dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7
         File: └─EFI/Ubuntu/grubx64.efi

Boot Loader Entries:
        $BOOT: /boot/efi (/dev/disk/by-partuuid/3aa3442b-045b-4b22-8e8b-6c01a5571ce7)

Default Boot Loader Entry:
        title: sdx4 - Ubuntu Desktop 22.04
           id: sdx4.conf
       source: /boot/efi/loader/entries/sdx4.conf
        linux: ../vmlinuz
       initrd: ../initrd.img
      options: root="PARTUUID=9d1de6a4-452c-42d2-bf18-acee90032326" rw

This begs many questions including:

Any thoughts about how to get systemd-boot to observe its configuration would be especially welcome.

ebsf1 commented 2 years ago

Further work and research reveals that the issue is that systemd-boot does not support the Boot Loader Specification. The command bootctl list is the syntax checker for boot loader entries conforming with the latter according to its documentation and returns:

        title: sdx3 - Ubuntu Desktop 22.04
           id: sdx3.conf
       source: /boot/loader/entries/sdx3.conf
        linux: ../vmlinuz
       initrd: ../initrd.img
      options: root=PARTUUID=[PARTUUID redacted] rw

        title: sdx4 - Ubuntu Desktop 22.04
           id: sdx4.conf
       source: /boot/loader/entries/sdx4.conf
        linux: /vmlinuz (No such file or directory)
       initrd: /initrd.img (No such file or directory)
      options: root=PARTUUID=[PARTUUID redacted] rw

So it is that we see that specifying the kernel files' location as being in the parent directory of the EFI System Partition's mount point by using the ../ path conforms not only with the language of the Boot Loader Specification (which I should hasten to add contains no language requiring kernel files to be located on the ESP) but also with the code that implements it.