Sdbootutil fails to create initrd and boot entry for snapshots and upgrades

I’ve been using systemd-boot for a few months and recently upgrades are failing to create new boot entries due to failing to generate initrd. It generates lots of error messages ‘… Argument list too long’ in snapper.log or on the console when running a command such as sdbootutil add-kernel 6.10.7-1-default 211 -v --no-reuse-initrd.

2024-09-05 21:11:57 MIL libsnapper(1815) SystemCmd.cc(SystemCmd):48 - constructor SystemCmd: /usr/lib/snapper/plugins/10-sdbootutil.snapper create-snapshot-post / btrfs 211
2024-09-05 21:12:05 MIL libsnapper(1815) SystemCmd.cc(addLine):394 - Adding Line 1 “/.snapshots/211/snapshot/usr/lib/dracut/dracut-init.sh: line 242: /.snapshots/211/snapshot/usr/lib/dracut/dracut-install: Argument list
too long”
2024-09-05 21:12:05 MIL libsnapper(1815) SystemCmd.cc(getUntilEOF):358 - pid:1837 added lines:1 stderr:true
2024-09-05 21:12:05 MIL libsnapper(1815) SystemCmd.cc(addLine):394 - Adding Line 2 “/.snapshots/211/snapshot/usr/lib/dracut/dracut-init.sh: line 1186: /usr/bin/ln: Argument list too long”
2024-09-05 21:12:05 MIL libsnapper(1815) SystemCmd.cc(getUntilEOF):358 - pid:1837 added lines:1 stderr:true
2024-09-05 21:12:05 MIL libsnapper(1815) SystemCmd.cc(addLine):394 - Adding Line 3 "/.snapshots/211/snapshot/usr/lib/dracut/dracut-init.sh: line 266: /.snapshots/211/snapshot/usr/lib/dracut/dracut-install: Argument list

The problem seems to be in the dracut file /usr/lib/dracut/dracut-init.sh lines 110-113 where it tries to add all sub-directories of /usr/lib64 into the LD_LIBRARY_PATH. Changing this to just add ‘$libdirs’ to the LD_LIBRARY_PATH will generate the initrd. Instead of adding the 3 needed dirs to the path it is trying to add over 6000 on my system.

There are also issues with sdbootutil and when using an XBOOTLDR partition for another post. (Or should I report those somewhere else?).

You need to open bug report on https://bugzilla.opensuse.org/, same user/password as here. This change is now upstream, and yes, it certainly looks wrong.

commit e0b876823d9c608db7132cab9e5edd62543a27ae
Author: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
Date:   Tue Aug 6 14:58:58 2024 +0200

    fix(dracut): ldd output borked with `--sysroot`
    
    dracut-install calls ldd to resolve dependencies, but when the `--sysroot`
    option is used, ldd is not performing the search within the sysroot directory.
    To fix this issue, the `LD_LIBRARY_PATH` variable needs to be properly set to
    the directories containing shared libraries within the specified sysroot
    directory.

Superficially we need to care for the standard directories and directories in DT_RUNPATH. E.g. for /usr/lib/systemd/systemd:

0x000000000000001d (RUNPATH)            Library runpath: [/lib/systemd]

Even better would be to compile systemd with $ORIGIN for the DT_RUNPATH which would automatically load libraries from the right place.

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