| Message ID | 7hseoy67prbdbhfbg3eq4aw7esyy34n53xtgimncistbold724@7av7tr6gpmfs |
|---|---|
| State | New |
| Headers | show |
| Series | x86_64: add systemd-boot images | expand |
Hi, On Tue, Dec 30, 2025 at 12:55 PM Jonas Lochmann <openwrt@jonaslochmann.de> wrote: > > grub2 has many features, including different implementations for loading > the linux kernel. At one machine, the "linux" command cannot start > OpenWrt while the "chainloader" command for the same kernel file works. > > Both commands use the same UEFI API, but the surrounding steps are > slightly different. An UEFI native bootloader seems to be similar to > "chainloader" in grub while avoiding a ton of extra features. One of > those bootloaders is systemd-boot, formerly known as gummiboot. > While it contains the name "systemd" and is part of the systemd > codebase, the resulting efi executable can be used independent of > systemd. systemd contains bootctl for managing a systemd-boot > installation, but systemd-boot uses simple text configuration files > so that this is not needed at all. I read this twice, and still don't know what this patch is trying to accomplish. What problem does this solve, or what new feature does this allow? I am missing a sentence or two explaining what the patch does and why. And you can probably trim the history part, e.g. I don't think it matters much for understanding that it used to be called gummiboot, as entertaining the name is. Best regards, (also) Jonas
The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. Hi, > > I read this twice, and still don't know what this patch is trying to > accomplish. What problem does this solve, or what new feature does > this allow? I am missing a sentence or two explaining what the patch > does and why. From my understanding it’s much simpler/smaller than GRUB, so maybe something inline with the efforts of OpenWrt? > > And you can probably trim the history part, e.g. I don't think it > matters much for understanding that it used to be called gummiboot, as > entertaining the name is. I found this rather helpful, since much documentation/form posts out there point to Gummiboot. Best, Paul
Am Tue, Dec 30, 2025 at 02:01:21PM +0100, schrieb Paul Spooren: > Hi, > > > > > I read this twice, and still don't know what this patch is trying to > > accomplish. What problem does this solve, or what new feature does > > this allow? I am missing a sentence or two explaining what the patch > > does and why. Maybe you read it twice because I posted it twice? I am sorry about that, but the first version had a small mistake that blocked updating the disk UUID after updates. > From my understanding it’s much simpler/smaller than GRUB, so maybe something inline with the efforts of OpenWrt? Yes, that's the main motivation. Unlike grub, it only supports UEFI boot but this is the only boot method supported by recent x86 hardware. The legacy boot procedure is relevant only in virtual machines but because this implementation uses (like the OpenWrt grub integration) the fallback path, no specific values in nvram variables are required so that UEFI booting works without effort - like the legacy boot. > > And you can probably trim the history part, e.g. I don't think it > > matters much for understanding that it used to be called gummiboot, as > > entertaining the name is. > > I found this rather helpful, since much documentation/form posts out there point to Gummiboot. Another thing is that gummiboot is packaged in the openwrt "packages" repository/feed. I don't know for what it is used (if at all), because there are no images that I know of that use it. Writing this detail (gummiboot is now systemd-boot) into the commit message makes it easier to state a reason why gummiboot can be removed from the repository once this was merged. Actually, I tried using gummiboot first and it resulted in a black screen only. I assume it still works at older hardware.
On Tue, Dec 30, 2025 at 3:05 PM Jonas Lochmann <openwrt@jonaslochmann.de> wrote: > > Am Tue, Dec 30, 2025 at 02:01:21PM +0100, schrieb Paul Spooren: > > Hi, > > > > > > > > I read this twice, and still don't know what this patch is trying to > > > accomplish. What problem does this solve, or what new feature does > > > this allow? I am missing a sentence or two explaining what the patch > > > does and why. > > Maybe you read it twice because I posted it twice? I am sorry about > that, but the first version had a small mistake that blocked updating > the disk UUID after updates. No, I definitely meant I read the text twice to see if I missed something. > > > From my understanding it’s much simpler/smaller than GRUB, so maybe something inline with the efforts of OpenWrt? Sure, but we shouldn't need to guess why something is added, that should be spelt out in the commit message. > > Yes, that's the main motivation. Unlike grub, it only supports UEFI > boot but this is the only boot method supported by recent x86 hardware. > The legacy boot procedure is relevant only in virtual machines but > because this implementation uses (like the OpenWrt grub integration) > the fallback path, no specific values in nvram variables are required > so that UEFI booting works without effort - like the legacy boot. The motivation should be part of the commit message, and currently it isn't. Like is this a potential replacement for something, or does it something different? Are there any drawbacks? etc. > > > > And you can probably trim the history part, e.g. I don't think it > > > matters much for understanding that it used to be called gummiboot, as > > > entertaining the name is. > > > > I found this rather helpful, since much documentation/form posts out there point to Gummiboot. > > Another thing is that gummiboot is packaged in the openwrt "packages" > repository/feed. I don't know for what it is used (if at all), because > there are no images that I know of that use it. > > Writing this detail (gummiboot is now systemd-boot) into the commit > message makes it easier to state a reason why gummiboot can be removed > from the repository once this was merged. Actually, I tried using > gummiboot first and it resulted in a black screen only. I assume it > still works at older hardware. Maybe then this should be also mentioned in the commit message? Especially since there are 0 mentions of gummiboot in the core OpenWrt repository. I tried to understand this commit from the perspective of here, and since gummiboot isn't mentioned (and used) there, the information seemed irrelevant for core OpenWrt. Best regards, Jonas
On Tue, Dec 30, 2025 at 03:05:16PM +0100, Jonas Lochmann wrote: > Am Tue, Dec 30, 2025 at 02:01:21PM +0100, schrieb Paul Spooren: > > > > From my understanding it’s much simpler/smaller than GRUB, so maybe something inline with the efforts of OpenWrt? > > Yes, that's the main motivation. Unlike grub, it only supports UEFI > boot but this is the only boot method supported by recent x86 hardware. The motherboard on this system is 3 years old yet will still boot using the traditional bootsector. Some things are disabled in that mode, but it can still boot without UEFI. This though isn't a bottom tier motherboard bought with price as the only criterion, nor is this a laptop which comes with fewer options. > The legacy boot procedure is relevant only in virtual machines but > because this implementation uses (like the OpenWrt grub integration) > the fallback path, no specific values in nvram variables are required > so that UEFI booting works without effort - like the legacy boot. Depends on the hypervisor and its configuration. Both GRUB and Tianocore/EDK2 have been ported to be directly loadable by at least one hypervisor and serve as the first stage loader. If GRUB is the first stage, then grub.cfg is the first OpenWRT built piece to be loaded. If Tianocore/EDK2 is the first stage, then it will be UEFI-only. On the surface the patch didn't look too problematic, but beware of making needless changes with booting. Of note SuSE chose to use "grub2.cfg" and has invested significant energy in keeping that. Resulting in pull #3791 which I'm unsure of working around a SuSE bug in OpenWRT.
Hi, I tested this with a small x86/64 config in libvirt / Virt Manager on Fedora. It boots up fine in a virtual machine with UEFI enabled and secure boot disabled. Systemd-boot is smaller than grub, sizes: openwrt-x86-64-generic-squashfs-rootfs.img.gz with grub2-efi: 4371163 openwrt-x86-64-generic-squashfs-rootfs.img.gz with systemd-boot: 4124862 (-5.6%, -240.5kB) openwrt-x86-64-generic-squashfs-combined-efi.img.gz: 10761442 openwrt-x86-64-generic-squashfs-systemd-boot.img.gz: 9964810 (-7.4%, -778kB) => Nice! But probably doesn't matter on x86 :-) But: sysupgrade the virtual machine to the same image fails: # sysupgrade /tmp/openwrt-x86-64-generic-squashfs-systemd-boot.img.gz Tue Dec 30 17:45:38 CET 2025 upgrade: Image metadata not present Tue Dec 30 17:45:38 CET 2025 upgrade: Invalid image type Image check failed. sysupgrade to the grub2-efi Image is ok: # sysupgrade /tmp/openwrt-x86-64-generic-squashfs-combined-efi.img.gz Tue Dec 30 18:14:42 CET 2025 upgrade: Image metadata not present Tue Dec 30 18:14:42 CET 2025 upgrade: with offset=0 devname=vda Tue Dec 30 18:14:42 CET 2025 upgrade: Reading partition table from bootdisk... Tue Dec 30 18:14:42 CET 2025 upgrade: Extract boot sector from the image Tue Dec 30 18:14:42 CET 2025 upgrade: Reading partition table from image... Tue Dec 30 18:14:42 CET 2025 upgrade: Saving config files... Tue Dec 30 18:14:42 CET 2025 upgrade: Commencing upgrade. Closing all shell sessions. Tue Dec 30 18:14:42 CET 2025 upgrade: Sending TERM to remaining processes ... Tue Dec 30 18:14:46 CET 2025 upgrade: Sending KILL to remaining processes ... stage2 (3617): drop_caches: 3 Tue Dec 30 18:14:52 CET 2025 upgrade: Switching to ramdisk... EXT4-fs (loop0): unmounting filesystem d13e0cae-a45a-42aa-a617-60f90bd2a9b1. Tue Dec 30 17:14:52 UTC 2025 upgrade: Performing system upgrade... [...] Compiling entire systemd to get systemd-boot seems a bit wasteful to me, but my patch to prevent this is bad. I removed Build/Install, since it kept compiling everything. diff --git a/package/boot/systemd-boot/Makefile b/package/boot/systemd-boot/Makefile index 425f53561d..18a5c095b0 100644 --- a/package/boot/systemd-boot/Makefile +++ b/package/boot/systemd-boot/Makefile @@ -19,7 +19,6 @@ PKG_CPE_ID:=cpe:/a:systemd_project:systemd:259:- PKG_LICENSE:=LGPL-2.1-or-later PKG_LICENSE_FILES:=LICENSES/README.md PKG_BUILD_DEPENDS:=python-pyelftools/host python-jinja2/host gperf/host -PKG_INSTALL:=1 MESON_USE_STAGING_PYTHON:=1 @@ -47,9 +46,16 @@ MESON_ARGS += \ -Dbootloader=enabled \ --auto-features=disabled +define Build/Compile + $(call Build/Compile/Meson,src/boot/systemd-bootx64.efi) +endef + +# removing PKG_INSTALL:=1 is not enough +undefine Build/Install + define Package/systemd-boot/install $(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/lib/systemd-boot - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/systemd/boot/efi/systemd-bootx64.efi $(1)/usr/lib/systemd-boot/ + $(INSTALL_DATA) $(MESON_BUILD_DIR)/src/boot/systemd-bootx64.efi $(1)/usr/lib/systemd-boot/ endef $(eval $(call BuildPackage,systemd-boot)) Am 30.12.25 um 12:54 schrieb Jonas Lochmann: > grub2 has many features, including different implementations for loading > the linux kernel. At one machine, the "linux" command cannot start > OpenWrt while the "chainloader" command for the same kernel file works. > > Both commands use the same UEFI API, but the surrounding steps are > slightly different. An UEFI native bootloader seems to be similar to > "chainloader" in grub while avoiding a ton of extra features. One of > those bootloaders is systemd-boot, formerly known as gummiboot. > While it contains the name "systemd" and is part of the systemd > codebase, the resulting efi executable can be used independent of > systemd. systemd contains bootctl for managing a systemd-boot > installation, but systemd-boot uses simple text configuration files > so that this is not needed at all. > > Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de> > --- > config/Config-images.in | 18 ++++-- > package/boot/systemd-boot/Makefile | 55 +++++++++++++++++++ > .../x86/base-files/lib/upgrade/platform.sh | 1 + > target/linux/x86/image/Makefile | 28 ++++++++++ > target/linux/x86/image/systemdboot-entry.cfg | 4 ++ > .../linux/x86/image/systemdboot-loader.conf | 1 + > 6 files changed, 101 insertions(+), 6 deletions(-) > create mode 100644 package/boot/systemd-boot/Makefile > create mode 100644 target/linux/x86/image/systemdboot-entry.cfg > create mode 100644 target/linux/x86/image/systemdboot-loader.conf > > diff --git a/config/Config-images.in b/config/Config-images.in > index fcc5fa52cb..ff93990834 100644 > --- a/config/Config-images.in > +++ b/config/Config-images.in > @@ -229,6 +229,12 @@ menu "Target Images" > prompt "journal size" if TARGET_ROOTFS_UBIFS > default "" > > + config SYSTEMDBOOT_IMAGES > + bool "Build systemd-boot images (EFI x86_64 targets only)" > + depends on TARGET_x86_64 > + depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS || TARGET_ROOTFS_EROFS > + select PACKAGE_systemd-boot > + > config GRUB_IMAGES > bool "Build GRUB images (Linux x86 or x86_64 host only)" > depends on TARGET_x86 > @@ -251,23 +257,23 @@ menu "Target Images" > > config GRUB_CONSOLE > bool "Use Console Terminal (in addition to Serial)" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default y > > config GRUB_BAUDRATE > int "Serial port baud rate" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default 38400 if TARGET_x86_generic > default 115200 > > config GRUB_FLOWCONTROL > bool "Use RTE/CTS on serial console" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > depends on TARGET_SERIAL != "" > > config GRUB_BOOTOPTS > string "Extra kernel boot options" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > help > If you don't know, just leave it blank. > > @@ -279,8 +285,8 @@ menu "Target Images" > If you don't know, 5 seconds is a reasonable default. > > config GRUB_TITLE > - string "Title for the menu entry in GRUB" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + string "Title for the menu entry in GRUB and systemd-boot" > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default "OpenWrt" > help > This is the title of the GRUB menu entry. > diff --git a/package/boot/systemd-boot/Makefile b/package/boot/systemd-boot/Makefile > new file mode 100644 > index 0000000000..425f53561d > --- /dev/null > +++ b/package/boot/systemd-boot/Makefile > @@ -0,0 +1,55 @@ > +# > +# This is free software, licensed under the GNU General Public License v2. > +# See /LICENSE for more information. > +# > + > +include $(TOPDIR)/rules.mk > + > +PKG_NAME:=systemd-boot > +PKG_VERSION:=259 > +PKG_RELEASE:=1 > + > +PKG_SOURCE_PROTO:=git > +PKG_SOURCE_URL:=https://github.com/systemd/systemd.git > +PKG_MIRROR_HASH:=1671487dc511d60d3c50070e8f5c6dec228a1d97cdedd7f5508a966bb06ba614 > +PKG_SOURCE_DATE:=2025-12-17 > +PKG_SOURCE_VERSION:=9ca433482f2281d71718718705ca8cd3bf562ad6 > +PKG_CPE_ID:=cpe:/a:systemd_project:systemd:259:- > + > +PKG_LICENSE:=LGPL-2.1-or-later > +PKG_LICENSE_FILES:=LICENSES/README.md > +PKG_BUILD_DEPENDS:=python-pyelftools/host python-jinja2/host gperf/host > +PKG_INSTALL:=1 > + > +MESON_USE_STAGING_PYTHON:=1 > + > +include $(INCLUDE_DIR)/package.mk > +include $(INCLUDE_DIR)/meson.mk > + > +define Package/systemd-boot > + SECTION:=boot > + CATEGORY:=Boot Loaders > + TITLE:=Simple UEFI boot manager > + DEPENDS:=@TARGET_x86_64 +libblkid > + URL:=https://github.com/systemd/systemd/tree/main/src/boot > +endef > + > +define Package/systemd-boot/description > + systemd-boot Simple UEFI boot manager > + > + systemd-boot executes EFI images. The default entry is selected by a configured > + pattern (glob) or an on-screen menu. > +endef > + > +MESON_ARGS += \ > + -Dmode=release \ > + -Dlibc=musl \ > + -Dbootloader=enabled \ > + --auto-features=disabled > + > +define Package/systemd-boot/install > + $(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/lib/systemd-boot > + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/systemd/boot/efi/systemd-bootx64.efi $(1)/usr/lib/systemd-boot/ > +endef > + > +$(eval $(call BuildPackage,systemd-boot)) > diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh > index 5dad7a538a..bca3d0426f 100644 > --- a/target/linux/x86/base-files/lib/upgrade/platform.sh > +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh > @@ -125,6 +125,7 @@ platform_do_upgrade() { > mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt > set -- $(dd if="/dev/$diskdev" bs=1 skip=1168 count=16 2>/dev/null | hexdump -v -e '8/1 "%02x "" "2/1 "%02x""-"6/1 "%02x"') > sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/boot/grub/grub.cfg > + sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/loader/entries/main.conf > umount /mnt > fi > } > diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile > index 29bebeb748..6f11712e87 100644 > --- a/target/linux/x86/image/Makefile > +++ b/target/linux/x86/image/Makefile > @@ -52,6 +52,30 @@ define Build/combined > 256 > endef > > +define Build/systemd-boot > + rm -fR $@.boot > + $(INSTALL_DIR) $@.boot/boot $@.boot/efi/boot $@.boot/loader/entries > + > + $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz > + -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/ > + $(CP) $(STAGING_DIR_ROOT)/usr/lib/systemd-boot/systemd-bootx64.efi $@.boot/efi/boot/bootx64.efi > + > + sed \ > + -e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \ > + -e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \ > + -e 's#@TITLE@#$(GRUB_TITLE)#g' \ > + ./systemdboot-entry.cfg > $@.boot/loader/entries/main.conf > + > + $(CP) ./systemdboot-loader.conf $@.boot/loader/loader.conf > + > + PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" \ > + GUID="$(IMG_PART_DISKGUID)" $(SCRIPT_DIR)/gen_image_generic.sh \ > + $@ \ > + $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \ > + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \ > + 256 > +endef > + > define Build/grub-config > rm -fR $@.boot > $(INSTALL_DIR) $@.boot/boot/grub > @@ -114,14 +138,18 @@ define Device/Default > IMAGE/combined-efi.vdi := grub-config efi | combined efi | grub-install efi | qemu-image vdi > IMAGE/combined-efi.vmdk := grub-config efi | combined efi | grub-install efi | qemu-image vmdk > IMAGE/combined-efi.vhdx := grub-config efi | combined efi | grub-install efi | qemu-image vhdx -o subformat=dynamic > + IMAGE/systemd-boot.img := systemd-boot | append-metadata > + IMAGE/systemd-boot.img.gz := systemd-boot | gzip | append-metadata > ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y) > IMAGES-y := rootfs.img.gz > IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img.gz > IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img.gz > + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img.gz > else > IMAGES-y := rootfs.img > IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img > IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img > + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img > endif > KERNEL := kernel-bin > KERNEL_INSTALL := 1 > diff --git a/target/linux/x86/image/systemdboot-entry.cfg b/target/linux/x86/image/systemdboot-entry.cfg > new file mode 100644 > index 0000000000..cf6bc659d0 > --- /dev/null > +++ b/target/linux/x86/image/systemdboot-entry.cfg > @@ -0,0 +1,4 @@ > +title @TITLE@ > +linux /boot/vmlinuz > +options @GPT_ROOTPART@ @CMDLINE@ noinitrd > +architecture x64 > diff --git a/target/linux/x86/image/systemdboot-loader.conf b/target/linux/x86/image/systemdboot-loader.conf > new file mode 100644 > index 0000000000..533d233153 > --- /dev/null > +++ b/target/linux/x86/image/systemdboot-loader.conf > @@ -0,0 +1 @@ > +timeout menu-disabled
Am Tue, Dec 30, 2025 at 06:30:43PM +0100, schrieb Stefan Hellermann: > I tested this with a small x86/64 config in libvirt / Virt Manager on > Fedora. It boots up fine in a virtual machine with UEFI enabled and secure > boot disabled. > > Systemd-boot is smaller than grub, sizes: > openwrt-x86-64-generic-squashfs-rootfs.img.gz with grub2-efi: 4371163 > openwrt-x86-64-generic-squashfs-rootfs.img.gz with systemd-boot: 4124862 > (-5.6%, -240.5kB) > openwrt-x86-64-generic-squashfs-combined-efi.img.gz: 10761442 > openwrt-x86-64-generic-squashfs-systemd-boot.img.gz: 9964810 (-7.4%, -778kB) > > => Nice! But probably doesn't matter on x86 :-) I know. > But: sysupgrade the virtual machine to the same image fails: > > # sysupgrade /tmp/openwrt-x86-64-generic-squashfs-systemd-boot.img.gz > Tue Dec 30 17:45:38 CET 2025 upgrade: Image metadata not present > Tue Dec 30 17:45:38 CET 2025 upgrade: Invalid image type > Image check failed. > > sysupgrade to the grub2-efi Image is ok: > > # sysupgrade /tmp/openwrt-x86-64-generic-squashfs-combined-efi.img.gz > Tue Dec 30 18:14:42 CET 2025 upgrade: Image metadata not present > Tue Dec 30 18:14:42 CET 2025 upgrade: with offset=0 devname=vda > Tue Dec 30 18:14:42 CET 2025 upgrade: Reading partition table from > bootdisk... > Tue Dec 30 18:14:42 CET 2025 upgrade: Extract boot sector from the image > Tue Dec 30 18:14:42 CET 2025 upgrade: Reading partition table from image... > Tue Dec 30 18:14:42 CET 2025 upgrade: Saving config files... > Tue Dec 30 18:14:42 CET 2025 upgrade: Commencing upgrade. Closing all shell > sessions. > Tue Dec 30 18:14:42 CET 2025 upgrade: Sending TERM to remaining processes > ... > Tue Dec 30 18:14:46 CET 2025 upgrade: Sending KILL to remaining processes > ... > stage2 (3617): drop_caches: 3 > Tue Dec 30 18:14:52 CET 2025 upgrade: Switching to ramdisk... > EXT4-fs (loop0): unmounting filesystem d13e0cae-a45a-42aa-a617-60f90bd2a9b1. > Tue Dec 30 17:14:52 UTC 2025 upgrade: Performing system upgrade... > [...] You need to force it. The platform specific (x86) upgrade code looks for certain magic bytes - I assume grub itself or data in the bios boot partition. I already know that cross upgrading between grub and systemd-boot works. The only limitation is that old builds without the code that adjusts the systemd-boot config file keep the wrong root partition parameter from the new image during the upgrade. > Compiling entire systemd to get systemd-boot seems a bit wasteful to me, but > my patch to prevent this is bad. I removed Build/Install, since it kept > compiling everything. I don't know how much of systemd building one can disable to still get systemd-boot. We could think about using more from systemd, but I don't think that would be a good fit for OpenWrt.
Am Tue, Dec 30, 2025 at 09:15:55AM -0800, schrieb Elliott Mitchell: > > Yes, that's the main motivation. Unlike grub, it only supports UEFI > > boot but this is the only boot method supported by recent x86 hardware. > > The motherboard on this system is 3 years old yet will still boot using > the traditional bootsector. Some things are disabled in that mode, but > it can still boot without UEFI. This though isn't a bottom tier > motherboard bought with price as the only criterion, nor is this a laptop > which comes with fewer options. "Starting with server platforms launching in 2020, Intel began phasing out support for Legacy Boot Mode. Starting with server platforms launching in 2024, Intel has discontinued support of Legacy Boot Mode in all segments." [1] > Depends on the hypervisor and its configuration. Both GRUB and > Tianocore/EDK2 have been ported to be directly loadable by at least one > hypervisor and serve as the first stage loader. If GRUB is the first > stage, then grub.cfg is the first OpenWRT built piece to be loaded. > If Tianocore/EDK2 is the first stage, then it will be UEFI-only. I know the theoretical option of loading grub as first stage in hypervisors and early in physical hardware. I never saw this beeing used in practice. > On the surface the patch didn't look too problematic, but beware of > making needless changes with booting. Of note SuSE chose to use > "grub2.cfg" and has invested significant energy in keeping that. > Resulting in pull #3791 which I'm unsure of working around a SuSE bug in > OpenWRT. That's why this is a new independent image type. Hybrid booting grub for legacy systems and systemd-boot for uefi would be possible, but useless. PR #3791 [2] is for using other grub builds? I would absolutely avoid that. It's like booting one distribution with another ones grub. It can work for a moment, but I would not expect it to be stable. I consider basic things like efi files the best possible entry point. The linux kernel itself can be executed by the uefi, but then I can not specify the command line parameters while still using the default path. systemd-boot is just used as a helper to fill this gap - read a config file and tell the uefi to load the actual kernel. It is possible to develop an own solution for this step - but it's not worth it. [1] https://cdrdv2-public.intel.com/630266/630266_WW31_2023.pdf [2] https://github.com/openwrt/openwrt/pull/3791/files
Hi, I integrated this patch into another tree without the packages feed. Then I get errors about missing dependencies: WARNING: Makefile 'package/boot/systemd-boot/Makefile' has a build dependency on 'python-pyelftools/host', which does not exist WARNING: Makefile 'package/boot/systemd-boot/Makefile' has a build dependency on 'python-jinja2/host', which does not exist and later python3 is missing: make[3]: Entering directory '/home/stefan/devel/openwrt2/package/boot/systemd-boot' systemd-boot fused dependencies: libc, libblkid1 rm -f /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/.configured_* rm -f /home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/stamp/.systemd-boot_installed /home/stefan/devel/openwrt2/staging_dir/host/bin/sed -e "s|@CC@|'/home/stefan/devel/openwrt2/staging_dir/host/bin/gcc',|" -e "s|@CXX@|'/home/stefan/devel/openwrt2/staging_dir/host/bin/g++',|" -e "s|@PKGCONFIG@|/home/stefan/devel/openwrt2/staging_dir/host/bin/pkg-config|" -e "s|@CMAKE@|/home/stefan/devel/openwrt2/staging_dir/host/bin/cmake|" -e "s|@PYTHON@|/home/stefan/devel/openwrt2/staging_dir/hostpkg/bin/python3|" -e "s|@CFLAGS@|'-O2', '-I/home/stefan/devel/openwrt2/staging_dir/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/hostpkg/include', '-I/home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/hostpkg/include', '-I/home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/host/include',|" -e "s|@CXXFLAGS@|'-O2', '-I/home/stefan/devel/openwrt2/staging_dir/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/hostpkg/include', '-I/home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/host/include', '-I/home/stefan/devel/openwrt2/staging_dir/hostpkg/include', '-I/home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/host/include',|" -e "s|@LDFLAGS@|'-L/home/stefan/devel/openwrt2/staging_dir/host/lib', '-L/home/stefan/devel/openwrt2/staging_dir/hostpkg/lib', '-L/home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/host/lib',|" -e "s|@PREFIX@||" < /home/stefan/devel/openwrt2/staging_dir/host/lib/meson/openwrt-native.txt.in > /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-native.txt /home/stefan/devel/openwrt2/staging_dir/host/bin/sed -e "s|@CC@|'x86_64-openwrt-linux-musl-gcc',|" -e "s|@CXX@|'x86_64-openwrt-linux-musl-g++',|" -e "s|@LD@|'bfd',|" -e "s|@AR@|x86_64-openwrt-linux-musl-gcc-ar|" -e "s|@STRIP@|x86_64-openwrt-linux-musl-strip|" -e "s|@NM@|x86_64-openwrt-linux-musl-gcc-nm|" -e "s|@PKGCONFIG@|/home/stefan/devel/openwrt2/staging_dir/host/bin/pkg-config|" -e "s|@CMAKE@|/home/stefan/devel/openwrt2/staging_dir/host/bin/cmake|" -e "s|@PYTHON@|/home/stefan/devel/openwrt2/staging_dir/hostpkg/bin/python3|" -e "s|@CFLAGS@|'-Os', '-pipe', '-fno-caller-saves', '-fno-plt', '-fhonour-copts', '-fmacro-prefix-map=/home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259=systemd-boot-259', '-Wformat', '-Werror=format-security', '-fstack-protector', '-D_FORTIFY_SOURCE=1', '-Wl,-z,now', '-Wl,-z,relro', '-Wl,-z,pack-relative-relocs', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/usr/include', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/include', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/include/fortify',|" -e "s|@CXXFLAGS@|'-Os', '-pipe', '-fno-caller-saves', '-fno-plt', '-fhonour-copts', '-fmacro-prefix-map=/home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259=systemd-boot-259', '-Wformat', '-Werror=format-security', '-fstack-protector', '-D_FORTIFY_SOURCE=1', '-Wl,-z,now', '-Wl,-z,relro', '-Wl,-z,pack-relative-relocs', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/usr/include', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/include', '-I/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/include/fortify',|" -e "s|@LDFLAGS@|'-L/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/usr/lib', '-L/home/stefan/devel/openwrt2/staging_dir/toolchain-x86_64_gcc-14.3.0_musl/lib', '-fuse-ld=bfd', '-znow', '-zrelro', '-zpack-relative-relocs',|" -e "s|@ARCH@|"x86_64"|" -e "s|@CPU@|"generic"|" -e "s|@ENDIAN@|little|" < /home/stefan/devel/openwrt2/staging_dir/host/lib/meson/openwrt-cross.txt.in > /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-cross.txt /home/stefan/devel/openwrt2/staging_dir/hostpkg/bin/python3 /home/stefan/devel/openwrt2/staging_dir/host/bin/meson.py setup --buildtype plain --native-file /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-native.txt --cross-file /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-cross.txt -Ddefault_library=both -Dmode=release -Dlibc=musl -Dbootloader=enabled --auto-features=disabled /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-build /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/openwrt-build/.. bash: line 1: /home/stefan/devel/openwrt2/staging_dir/hostpkg/bin/python3: No such file or directory make[3]: *** [Makefile:62: /home/stefan/devel/openwrt2/build_dir/target-x86_64_musl/systemd-boot-259/.configured_68b329da9893e34099c7d8ad5cb9c940] Error 127 make[3]: Leaving directory '/home/stefan/devel/openwrt2/package/boot/systemd-boot' time: package/boot/systemd-boot/compile#0.10#0.11#0.20 ERROR: package/boot/systemd-boot failed to build. make[2]: *** [package/Makefile:187: package/boot/systemd-boot/compile] Error 1 make[2]: Leaving directory '/home/stefan/devel/openwrt2' make[1]: *** [package/Makefile:181: /home/stefan/devel/openwrt2/staging_dir/target-x86_64_musl/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/stefan/devel/openwrt2' make: *** [/home/stefan/devel/openwrt2/include/toplevel.mk:233: world] Fehler 2 No easy fix :-) I think it will be difficult to integrate all the dependencies into openwrt in order to compile the entire systemd with it... Have you thought about integrating the boot cmdline into the kernel (CONFIG_CMDLINE) and just put the kernel to /boot/efi/boot/bootx64.efi ? Or the new UKI-Format? Best regards, Stefan Am 30.12.25 um 12:54 schrieb Jonas Lochmann: > grub2 has many features, including different implementations for loading > the linux kernel. At one machine, the "linux" command cannot start > OpenWrt while the "chainloader" command for the same kernel file works. > > Both commands use the same UEFI API, but the surrounding steps are > slightly different. An UEFI native bootloader seems to be similar to > "chainloader" in grub while avoiding a ton of extra features. One of > those bootloaders is systemd-boot, formerly known as gummiboot. > While it contains the name "systemd" and is part of the systemd > codebase, the resulting efi executable can be used independent of > systemd. systemd contains bootctl for managing a systemd-boot > installation, but systemd-boot uses simple text configuration files > so that this is not needed at all. > > Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de> > --- > config/Config-images.in | 18 ++++-- > package/boot/systemd-boot/Makefile | 55 +++++++++++++++++++ > .../x86/base-files/lib/upgrade/platform.sh | 1 + > target/linux/x86/image/Makefile | 28 ++++++++++ > target/linux/x86/image/systemdboot-entry.cfg | 4 ++ > .../linux/x86/image/systemdboot-loader.conf | 1 + > 6 files changed, 101 insertions(+), 6 deletions(-) > create mode 100644 package/boot/systemd-boot/Makefile > create mode 100644 target/linux/x86/image/systemdboot-entry.cfg > create mode 100644 target/linux/x86/image/systemdboot-loader.conf > > diff --git a/config/Config-images.in b/config/Config-images.in > index fcc5fa52cb..ff93990834 100644 > --- a/config/Config-images.in > +++ b/config/Config-images.in > @@ -229,6 +229,12 @@ menu "Target Images" > prompt "journal size" if TARGET_ROOTFS_UBIFS > default "" > > + config SYSTEMDBOOT_IMAGES > + bool "Build systemd-boot images (EFI x86_64 targets only)" > + depends on TARGET_x86_64 > + depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS || TARGET_ROOTFS_EROFS > + select PACKAGE_systemd-boot > + > config GRUB_IMAGES > bool "Build GRUB images (Linux x86 or x86_64 host only)" > depends on TARGET_x86 > @@ -251,23 +257,23 @@ menu "Target Images" > > config GRUB_CONSOLE > bool "Use Console Terminal (in addition to Serial)" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default y > > config GRUB_BAUDRATE > int "Serial port baud rate" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default 38400 if TARGET_x86_generic > default 115200 > > config GRUB_FLOWCONTROL > bool "Use RTE/CTS on serial console" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > depends on TARGET_SERIAL != "" > > config GRUB_BOOTOPTS > string "Extra kernel boot options" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > help > If you don't know, just leave it blank. > > @@ -279,8 +285,8 @@ menu "Target Images" > If you don't know, 5 seconds is a reasonable default. > > config GRUB_TITLE > - string "Title for the menu entry in GRUB" > - depends on GRUB_IMAGES || GRUB_EFI_IMAGES > + string "Title for the menu entry in GRUB and systemd-boot" > + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES > default "OpenWrt" > help > This is the title of the GRUB menu entry. > diff --git a/package/boot/systemd-boot/Makefile b/package/boot/systemd-boot/Makefile > new file mode 100644 > index 0000000000..425f53561d > --- /dev/null > +++ b/package/boot/systemd-boot/Makefile > @@ -0,0 +1,55 @@ > +# > +# This is free software, licensed under the GNU General Public License v2. > +# See /LICENSE for more information. > +# > + > +include $(TOPDIR)/rules.mk > + > +PKG_NAME:=systemd-boot > +PKG_VERSION:=259 > +PKG_RELEASE:=1 > + > +PKG_SOURCE_PROTO:=git > +PKG_SOURCE_URL:=https://github.com/systemd/systemd.git > +PKG_MIRROR_HASH:=1671487dc511d60d3c50070e8f5c6dec228a1d97cdedd7f5508a966bb06ba614 > +PKG_SOURCE_DATE:=2025-12-17 > +PKG_SOURCE_VERSION:=9ca433482f2281d71718718705ca8cd3bf562ad6 > +PKG_CPE_ID:=cpe:/a:systemd_project:systemd:259:- > + > +PKG_LICENSE:=LGPL-2.1-or-later > +PKG_LICENSE_FILES:=LICENSES/README.md > +PKG_BUILD_DEPENDS:=python-pyelftools/host python-jinja2/host gperf/host > +PKG_INSTALL:=1 > + > +MESON_USE_STAGING_PYTHON:=1 > + > +include $(INCLUDE_DIR)/package.mk > +include $(INCLUDE_DIR)/meson.mk > + > +define Package/systemd-boot > + SECTION:=boot > + CATEGORY:=Boot Loaders > + TITLE:=Simple UEFI boot manager > + DEPENDS:=@TARGET_x86_64 +libblkid > + URL:=https://github.com/systemd/systemd/tree/main/src/boot > +endef > + > +define Package/systemd-boot/description > + systemd-boot Simple UEFI boot manager > + > + systemd-boot executes EFI images. The default entry is selected by a configured > + pattern (glob) or an on-screen menu. > +endef > + > +MESON_ARGS += \ > + -Dmode=release \ > + -Dlibc=musl \ > + -Dbootloader=enabled \ > + --auto-features=disabled > + > +define Package/systemd-boot/install > + $(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/lib/systemd-boot > + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/systemd/boot/efi/systemd-bootx64.efi $(1)/usr/lib/systemd-boot/ > +endef > + > +$(eval $(call BuildPackage,systemd-boot)) > diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh > index 5dad7a538a..bca3d0426f 100644 > --- a/target/linux/x86/base-files/lib/upgrade/platform.sh > +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh > @@ -125,6 +125,7 @@ platform_do_upgrade() { > mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt > set -- $(dd if="/dev/$diskdev" bs=1 skip=1168 count=16 2>/dev/null | hexdump -v -e '8/1 "%02x "" "2/1 "%02x""-"6/1 "%02x"') > sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/boot/grub/grub.cfg > + sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/loader/entries/main.conf > umount /mnt > fi > } > diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile > index 29bebeb748..6f11712e87 100644 > --- a/target/linux/x86/image/Makefile > +++ b/target/linux/x86/image/Makefile > @@ -52,6 +52,30 @@ define Build/combined > 256 > endef > > +define Build/systemd-boot > + rm -fR $@.boot > + $(INSTALL_DIR) $@.boot/boot $@.boot/efi/boot $@.boot/loader/entries > + > + $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz > + -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/ > + $(CP) $(STAGING_DIR_ROOT)/usr/lib/systemd-boot/systemd-bootx64.efi $@.boot/efi/boot/bootx64.efi > + > + sed \ > + -e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \ > + -e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \ > + -e 's#@TITLE@#$(GRUB_TITLE)#g' \ > + ./systemdboot-entry.cfg > $@.boot/loader/entries/main.conf > + > + $(CP) ./systemdboot-loader.conf $@.boot/loader/loader.conf > + > + PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" \ > + GUID="$(IMG_PART_DISKGUID)" $(SCRIPT_DIR)/gen_image_generic.sh \ > + $@ \ > + $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \ > + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \ > + 256 > +endef > + > define Build/grub-config > rm -fR $@.boot > $(INSTALL_DIR) $@.boot/boot/grub > @@ -114,14 +138,18 @@ define Device/Default > IMAGE/combined-efi.vdi := grub-config efi | combined efi | grub-install efi | qemu-image vdi > IMAGE/combined-efi.vmdk := grub-config efi | combined efi | grub-install efi | qemu-image vmdk > IMAGE/combined-efi.vhdx := grub-config efi | combined efi | grub-install efi | qemu-image vhdx -o subformat=dynamic > + IMAGE/systemd-boot.img := systemd-boot | append-metadata > + IMAGE/systemd-boot.img.gz := systemd-boot | gzip | append-metadata > ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y) > IMAGES-y := rootfs.img.gz > IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img.gz > IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img.gz > + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img.gz > else > IMAGES-y := rootfs.img > IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img > IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img > + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img > endif > KERNEL := kernel-bin > KERNEL_INSTALL := 1 > diff --git a/target/linux/x86/image/systemdboot-entry.cfg b/target/linux/x86/image/systemdboot-entry.cfg > new file mode 100644 > index 0000000000..cf6bc659d0 > --- /dev/null > +++ b/target/linux/x86/image/systemdboot-entry.cfg > @@ -0,0 +1,4 @@ > +title @TITLE@ > +linux /boot/vmlinuz > +options @GPT_ROOTPART@ @CMDLINE@ noinitrd > +architecture x64 > diff --git a/target/linux/x86/image/systemdboot-loader.conf b/target/linux/x86/image/systemdboot-loader.conf > new file mode 100644 > index 0000000000..533d233153 > --- /dev/null > +++ b/target/linux/x86/image/systemdboot-loader.conf > @@ -0,0 +1 @@ > +timeout menu-disabled
On Tue, Dec 30, 2025 at 07:51:29PM +0100, Jonas Lochmann wrote: > Am Tue, Dec 30, 2025 at 09:15:55AM -0800, schrieb Elliott Mitchell: > > > Yes, that's the main motivation. Unlike grub, it only supports UEFI > > > boot but this is the only boot method supported by recent x86 hardware. > > > > The motherboard on this system is 3 years old yet will still boot using > > the traditional bootsector. Some things are disabled in that mode, but > > it can still boot without UEFI. This though isn't a bottom tier > > motherboard bought with price as the only criterion, nor is this a laptop > > which comes with fewer options. > > "Starting with server platforms launching in 2020, Intel began phasing out > support for Legacy Boot Mode. Starting with server platforms launching in > 2024, Intel has discontinued support of Legacy Boot Mode in all segments." [1] I'm well-aware x86 bootsector booting is being killed. UEFI is better in several ways, but rather higher overhead. Yet it was still possible to purchase current-generation hardware with bootsector support. I also note that is *Intel*, not every company which has ever produced an x86-compatible processor. Not a strong argument, merely a comment bootsector will be around a long time. OpenWRT x86 images in theory support hardware manufactured in 1995, so bootsector support will need to stick around a long time. > > Depends on the hypervisor and its configuration. Both GRUB and > > Tianocore/EDK2 have been ported to be directly loadable by at least one > > hypervisor and serve as the first stage loader. If GRUB is the first > > stage, then grub.cfg is the first OpenWRT built piece to be loaded. > > If Tianocore/EDK2 is the first stage, then it will be UEFI-only. > > I know the theoretical option of loading grub as first stage in > hypervisors and early in physical hardware. I never saw this beeing used > in practice. I guess this shows we're in different circles. GRUB-PV is recommended for booting Linux images on Xen, most Linux distributions document this and have packages available. > > On the surface the patch didn't look too problematic, but beware of > > making needless changes with booting. Of note SuSE chose to use > > "grub2.cfg" and has invested significant energy in keeping that. > > Resulting in pull #3791 which I'm unsure of working around a SuSE bug in > > OpenWRT. > > That's why this is a new independent image type. Hybrid booting grub > for legacy systems and systemd-boot for uefi would be possible, but > useless. > > PR #3791 [2] is for using other grub builds? I would absolutely avoid > that. It's like booting one distribution with another ones grub. It can > work for a moment, but I would not expect it to be stable. I consider Such is quite stable. Unlike Python, GRUBv2's configuration file syntax has been quite stable. Since 2.0 most changes have been bugfixes and module additions. There was talk of chainloading the VM's version of GRUB to ensure compatibility, but to my knowledge that has merely been proposed. > basic things like efi files the best possible entry point. The linux > kernel itself can be executed by the uefi, but then I can not specify > the command line parameters while still using the default path. > systemd-boot is just used as a helper to fill this gap - read a config > file and tell the uefi to load the actual kernel. It is possible to > develop an own solution for this step - but it's not worth it. There is one key thing which GRUB allows, but this doesn't claim to. GRUB allows having multiple kernels installed and choosing between them. Not too urgent for most OpenWRT targets, but critical kernel bugs do show up. Being able to keep an older known working kernel around has been extremely helpful. This might mostly be an issue for x86 which has a great deal of drivers available and plenty of space to keep one or two older kernels around. Yet for x86 it is big win. (typing as someone who recently ran into such a severe bug)
Am Tue, Dec 30, 2025 at 01:43:15PM -0800, schrieb Elliott Mitchell: > I'm well-aware x86 bootsector booting is being killed. UEFI is better in > several ways, but rather higher overhead. Yet it was still possible to > purchase current-generation hardware with bootsector support. I also > note that is *Intel*, not every company which has ever produced an > x86-compatible processor. > > Not a strong argument, merely a comment bootsector will be around a long > time. OpenWRT x86 images in theory support hardware manufactured in > 1995, so bootsector support will need to stick around a long time. I don't have the goal to remove grub based booting - so legacy booting will continue working. > > I know the theoretical option of loading grub as first stage in > > hypervisors and early in physical hardware. I never saw this beeing used > > in practice. > > I guess this shows we're in different circles. GRUB-PV is recommended > for booting Linux images on Xen, most Linux distributions document this > and have packages available. I found a description from Debian and it does not sound like a recommendation but like one possible solution [1]. I am working with KVM for virtualization. > Such is quite stable. Unlike Python, GRUBv2's configuration file syntax > has been quite stable. Since 2.0 most changes have been bugfixes and > module additions. There was talk of chainloading the VM's version of > GRUB to ensure compatibility, but to my knowledge that has merely been > proposed. The grub version and the provided modules and the modules included by the grub.cfg differ between distributions. I remember beeing able to boot Fedora from a f2fs partition using Debians grub, but not using Fedoras grub. If you load a kernel from a efi partition, then all distributions should be able to handle it - but then you don't need grub at all. > > basic things like efi files the best possible entry point. The linux > > kernel itself can be executed by the uefi, but then I can not specify > > the command line parameters while still using the default path. > > systemd-boot is just used as a helper to fill this gap - read a config > > file and tell the uefi to load the actual kernel. It is possible to > > develop an own solution for this step - but it's not worth it. > > There is one key thing which GRUB allows, but this doesn't claim to. > GRUB allows having multiple kernels installed and choosing between them. > Not too urgent for most OpenWRT targets, but critical kernel bugs do > show up. Being able to keep an older known working kernel around has > been extremely helpful. systemd-boot allows that too. With boot counting [2], it can automatically fall back to an older kernel if the new one has problems. [1] https://wiki.debian.org/PvGrub [2] https://uapi-group.org/specifications/specs/boot_loader_specification/#boot-counting
Am Tue, Dec 30, 2025 at 09:12:06PM +0100, schrieb Stefan Hellermann: > Hi, > > I integrated this patch into another tree without the packages feed. Then I > get errors about missing dependencies: > > WARNING: Makefile 'package/boot/systemd-boot/Makefile' has a build > dependency on 'python-pyelftools/host', which does not exist > WARNING: Makefile 'package/boot/systemd-boot/Makefile' has a build > dependency on 'python-jinja2/host', which does not exist > > and later python3 is missing: > [...] > > No easy fix :-) I think it will be difficult to integrate all the > dependencies into openwrt in order to compile the entire systemd with it... I just use a recent OpenWrt release candidate and both dependencies are packed there. > Have you thought about integrating the boot cmdline into the kernel > (CONFIG_CMDLINE) and just put the kernel to /boot/efi/boot/bootx64.efi ? Or > the new UKI-Format? Yes, and this prevents editing the boot parameters which is something that the sysupgrade does. Editing the binary file could work, but is something I consider a bad idea.
The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. On 12/30/25 22:43, Elliott Mitchell wrote: > On Tue, Dec 30, 2025 at 07:51:29PM +0100, Jonas Lochmann wrote: > There is one key thing which GRUB allows, but this doesn't claim to. > GRUB allows having multiple kernels installed and choosing between them. I find this a strange request since this feature isn't used in Openwrt on x86 (or any other target) afaik. Best you get is A/B kernel+rootfs partitions setups on some devices but it's not the same thing. There is also a PR for A/B partitions on x86 btw https://github.com/openwrt/openwrt/pull/2951 All x86 bootloaders let you have multiple kernels set up for booting and choose on start (with a default that will be booted automatically), grub, systemd-boot, refind, limine. Even very old ones like LILO let you do that. But the distro has to be set up to do that first, distributing kernels as a package that can be installed independently and so on. Afaik the only way to "upgrade the kernel" on OpenWrt is doing a sysupgrade, and that will take care of putting the kernel where it needs to be and removing the old one. -Alberto
Am Tue, Dec 30, 2025 at 07:51:22PM +0100, schrieb Jonas Lochmann: > Am Tue, Dec 30, 2025 at 06:30:43PM +0100, schrieb Stefan Hellermann: > > But: sysupgrade the virtual machine to the same image fails: > > You need to force it. The platform specific (x86) upgrade code looks > for certain magic bytes - I assume grub itself or data in the bios boot > partition. With my "[PATCH] x86: check for gpt header in platform_check_image" this issue does not occur anymore. The old upgrade routine checked for BIOS boot code in the MBR, which an UEFI only image does not contain.
diff --git a/config/Config-images.in b/config/Config-images.in index fcc5fa52cb..ff93990834 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -229,6 +229,12 @@ menu "Target Images" prompt "journal size" if TARGET_ROOTFS_UBIFS default "" + config SYSTEMDBOOT_IMAGES + bool "Build systemd-boot images (EFI x86_64 targets only)" + depends on TARGET_x86_64 + depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS || TARGET_ROOTFS_EROFS + select PACKAGE_systemd-boot + config GRUB_IMAGES bool "Build GRUB images (Linux x86 or x86_64 host only)" depends on TARGET_x86 @@ -251,23 +257,23 @@ menu "Target Images" config GRUB_CONSOLE bool "Use Console Terminal (in addition to Serial)" - depends on GRUB_IMAGES || GRUB_EFI_IMAGES + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES default y config GRUB_BAUDRATE int "Serial port baud rate" - depends on GRUB_IMAGES || GRUB_EFI_IMAGES + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES default 38400 if TARGET_x86_generic default 115200 config GRUB_FLOWCONTROL bool "Use RTE/CTS on serial console" - depends on GRUB_IMAGES || GRUB_EFI_IMAGES + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES depends on TARGET_SERIAL != "" config GRUB_BOOTOPTS string "Extra kernel boot options" - depends on GRUB_IMAGES || GRUB_EFI_IMAGES + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES help If you don't know, just leave it blank. @@ -279,8 +285,8 @@ menu "Target Images" If you don't know, 5 seconds is a reasonable default. config GRUB_TITLE - string "Title for the menu entry in GRUB" - depends on GRUB_IMAGES || GRUB_EFI_IMAGES + string "Title for the menu entry in GRUB and systemd-boot" + depends on GRUB_IMAGES || GRUB_EFI_IMAGES || SYSTEMDBOOT_IMAGES default "OpenWrt" help This is the title of the GRUB menu entry. diff --git a/package/boot/systemd-boot/Makefile b/package/boot/systemd-boot/Makefile new file mode 100644 index 0000000000..425f53561d --- /dev/null +++ b/package/boot/systemd-boot/Makefile @@ -0,0 +1,55 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=systemd-boot +PKG_VERSION:=259 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/systemd/systemd.git +PKG_MIRROR_HASH:=1671487dc511d60d3c50070e8f5c6dec228a1d97cdedd7f5508a966bb06ba614 +PKG_SOURCE_DATE:=2025-12-17 +PKG_SOURCE_VERSION:=9ca433482f2281d71718718705ca8cd3bf562ad6 +PKG_CPE_ID:=cpe:/a:systemd_project:systemd:259:- + +PKG_LICENSE:=LGPL-2.1-or-later +PKG_LICENSE_FILES:=LICENSES/README.md +PKG_BUILD_DEPENDS:=python-pyelftools/host python-jinja2/host gperf/host +PKG_INSTALL:=1 + +MESON_USE_STAGING_PYTHON:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/meson.mk + +define Package/systemd-boot + SECTION:=boot + CATEGORY:=Boot Loaders + TITLE:=Simple UEFI boot manager + DEPENDS:=@TARGET_x86_64 +libblkid + URL:=https://github.com/systemd/systemd/tree/main/src/boot +endef + +define Package/systemd-boot/description + systemd-boot Simple UEFI boot manager + + systemd-boot executes EFI images. The default entry is selected by a configured + pattern (glob) or an on-screen menu. +endef + +MESON_ARGS += \ + -Dmode=release \ + -Dlibc=musl \ + -Dbootloader=enabled \ + --auto-features=disabled + +define Package/systemd-boot/install + $(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/lib/systemd-boot + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/systemd/boot/efi/systemd-bootx64.efi $(1)/usr/lib/systemd-boot/ +endef + +$(eval $(call BuildPackage,systemd-boot)) diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 5dad7a538a..bca3d0426f 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -125,6 +125,7 @@ platform_do_upgrade() { mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt set -- $(dd if="/dev/$diskdev" bs=1 skip=1168 count=16 2>/dev/null | hexdump -v -e '8/1 "%02x "" "2/1 "%02x""-"6/1 "%02x"') sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/boot/grub/grub.cfg + sed -i "s/\(PARTUUID=\)[a-f0-9-]\+/\1$4$3$2$1-$6$5-$8$7-$9/ig" /mnt/loader/entries/main.conf umount /mnt fi } diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index 29bebeb748..6f11712e87 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -52,6 +52,30 @@ define Build/combined 256 endef +define Build/systemd-boot + rm -fR $@.boot + $(INSTALL_DIR) $@.boot/boot $@.boot/efi/boot $@.boot/loader/entries + + $(CP) $(KDIR)/$(KERNEL_NAME) $@.boot/boot/vmlinuz + -$(CP) $(STAGING_DIR_ROOT)/boot/. $@.boot/boot/ + $(CP) $(STAGING_DIR_ROOT)/usr/lib/systemd-boot/systemd-bootx64.efi $@.boot/efi/boot/bootx64.efi + + sed \ + -e 's#@GPT_ROOTPART@#root=$(GPT_ROOTPART) rootwait#g' \ + -e 's#@CMDLINE@#$(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE)#g' \ + -e 's#@TITLE@#$(GRUB_TITLE)#g' \ + ./systemdboot-entry.cfg > $@.boot/loader/entries/main.conf + + $(CP) ./systemdboot-loader.conf $@.boot/loader/loader.conf + + PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" \ + GUID="$(IMG_PART_DISKGUID)" $(SCRIPT_DIR)/gen_image_generic.sh \ + $@ \ + $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \ + 256 +endef + define Build/grub-config rm -fR $@.boot $(INSTALL_DIR) $@.boot/boot/grub @@ -114,14 +138,18 @@ define Device/Default IMAGE/combined-efi.vdi := grub-config efi | combined efi | grub-install efi | qemu-image vdi IMAGE/combined-efi.vmdk := grub-config efi | combined efi | grub-install efi | qemu-image vmdk IMAGE/combined-efi.vhdx := grub-config efi | combined efi | grub-install efi | qemu-image vhdx -o subformat=dynamic + IMAGE/systemd-boot.img := systemd-boot | append-metadata + IMAGE/systemd-boot.img.gz := systemd-boot | gzip | append-metadata ifeq ($(CONFIG_TARGET_IMAGES_GZIP),y) IMAGES-y := rootfs.img.gz IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img.gz IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img.gz + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img.gz else IMAGES-y := rootfs.img IMAGES-$$(CONFIG_GRUB_IMAGES) += combined.img IMAGES-$$(CONFIG_GRUB_EFI_IMAGES) += combined-efi.img + IMAGES-$$(CONFIG_SYSTEMDBOOT_IMAGES) += systemd-boot.img endif KERNEL := kernel-bin KERNEL_INSTALL := 1 diff --git a/target/linux/x86/image/systemdboot-entry.cfg b/target/linux/x86/image/systemdboot-entry.cfg new file mode 100644 index 0000000000..cf6bc659d0 --- /dev/null +++ b/target/linux/x86/image/systemdboot-entry.cfg @@ -0,0 +1,4 @@ +title @TITLE@ +linux /boot/vmlinuz +options @GPT_ROOTPART@ @CMDLINE@ noinitrd +architecture x64 diff --git a/target/linux/x86/image/systemdboot-loader.conf b/target/linux/x86/image/systemdboot-loader.conf new file mode 100644 index 0000000000..533d233153 --- /dev/null +++ b/target/linux/x86/image/systemdboot-loader.conf @@ -0,0 +1 @@ +timeout menu-disabled
grub2 has many features, including different implementations for loading the linux kernel. At one machine, the "linux" command cannot start OpenWrt while the "chainloader" command for the same kernel file works. Both commands use the same UEFI API, but the surrounding steps are slightly different. An UEFI native bootloader seems to be similar to "chainloader" in grub while avoiding a ton of extra features. One of those bootloaders is systemd-boot, formerly known as gummiboot. While it contains the name "systemd" and is part of the systemd codebase, the resulting efi executable can be used independent of systemd. systemd contains bootctl for managing a systemd-boot installation, but systemd-boot uses simple text configuration files so that this is not needed at all. Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de> --- config/Config-images.in | 18 ++++-- package/boot/systemd-boot/Makefile | 55 +++++++++++++++++++ .../x86/base-files/lib/upgrade/platform.sh | 1 + target/linux/x86/image/Makefile | 28 ++++++++++ target/linux/x86/image/systemdboot-entry.cfg | 4 ++ .../linux/x86/image/systemdboot-loader.conf | 1 + 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 package/boot/systemd-boot/Makefile create mode 100644 target/linux/x86/image/systemdboot-entry.cfg create mode 100644 target/linux/x86/image/systemdboot-loader.conf