Bug#1020396: systemd-boot: kernel installation/initrd update hooks double the initrd like #970213 since #826045

наб nabijaczleweli at nabijaczleweli.xyz
Wed Sep 21 02:25:48 BST 2022


Package: systemd-boot
Version: 251.4-3
Severity: normal
Tags: patch

Dear Maintainer,

In the default installation, both a bare initrd and a versioned one are
installed:
  /boot/efi/HASH/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  /boot/efi/HASH/5.16.0-1-amd64/linux
  /boot/efi/HASH/5.16.0-1-amd64/initrd

In #970213, I worked around this by only installing the generated
as the standard "initrd" fallback if none was passed;
I've been using a simple 
  #!/bin/sh
  bootctl is-installed > /dev/null || exit 0
  exec kernel-install add "$1" "/boot/vmlinuz-$1" "/boot/initrd.img-$1"
/etc/kernel/postinst.d/kernel-install (and analogous remove),
so this works for that case perfectly.

In #826045, upstream hooks were added:
  debian/extra/kernel/post{inst,rm}.d/systemd-boot
  (74127387dacf23f037f3a55a808951fae93024c6)
and
  debian/extra/initramfs/post-update.d/systemd-boot
  (9a6d87f1c6f7fbde8ff8e7beab30973944221244)
to integrate with bootctl out-of-box. This is great!

However, /etc/kernel/postinst.d/systemd-boot runs:
  kernel-install add "$1" "$2"
and /etc/initramfs/post-update.d/systemd-boot runs:
  kernel-install add "$1" "/boot/vmlinuz-$1" "$2"

And the former installs:
  /boot/efi/HASH/5.16.0-1-amd64/linux
  /boot/efi/HASH/5.16.0-1-amd64/initrd
but the latter installs:
  /boot/efi/HASH/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  /boot/efi/HASH/5.16.0-1-amd64/linux
hence the situation at the top I wanted to avoid in #970213;
ESPs tend to be really small!

I've opened MR 169 on Salsa:
  https://salsa.debian.org/systemd-team/systemd/-/merge_requests/169
and am attaching a patch for this that makes it so
/etc/kernel/postinst.d/systemd-boot calls 
  kernel-install add "$1" "$2" "/boot/initrd.img-$1"
if the latter exists, and the previous
  kernel-install add "$1" "$2"
otherwise, which always installs the versioned initrd,
as well as one that will order this bootloader hook
with the other bootloader hooks at the end (cf. message).


Installation logs that demonstrate this follow.

Implicit image:
  root at zoot2:~# kernel-install -v add $(uname -r) /boot/vmlinuz-5.16.0-1-amd64
  Reading /usr/lib/kernel/install.conf…
  BOOT_ROOT=/tmp/br set via environment or install.conf
  machine-id d42f27f4670847aeae24b01bd283a4e0 acquired from /etc/machine-id
  Entry-token candidates: d42f27f4670847aeae24b01bd283a4e0 debian Default
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using BOOT_ROOT=/tmp/br, ENTRY_TOKEN=d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using layout=bls
  Using ENTRY_DIR_ABS=/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  Plugin files:
  /usr/lib/kernel/install.d/50-depmod.install
  /usr/lib/kernel/install.d/85-initrd.install
  /usr/lib/kernel/install.d/90-loaderentry.install
  +mkdir -v -p /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  mkdir: created directory '/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64'
  +/usr/lib/kernel/install.d/50-depmod.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64
  +depmod -a 5.16.0-1-amd64
  +/usr/lib/kernel/install.d/85-initrd.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64
  Installing '/boot/initrd.img-5.16.0-1-amd64' as '/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd'
  +/usr/lib/kernel/install.d/90-loaderentry.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64
  Creating /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf
  root at zoot2:~# find /tmp/br/
  /tmp/br/
  /tmp/br/loader
  /tmp/br/loader/entries
  /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/linux
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd

Explicit image:
  root at zoot2:~# kernel-install -v add $(uname -r) /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.0-1-amd64
  Reading /usr/lib/kernel/install.conf…
  BOOT_ROOT=/tmp/br set via environment or install.conf
  machine-id d42f27f4670847aeae24b01bd283a4e0 acquired from /etc/machine-id
  Entry-token candidates: d42f27f4670847aeae24b01bd283a4e0 debian Default
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using BOOT_ROOT=/tmp/br, ENTRY_TOKEN=d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using layout=bls
  Using ENTRY_DIR_ABS=/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  Plugin files:
  /usr/lib/kernel/install.d/50-depmod.install
  /usr/lib/kernel/install.d/85-initrd.install
  /usr/lib/kernel/install.d/90-loaderentry.install
  +mkdir -v -p /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  mkdir: created directory '/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64'
  +/usr/lib/kernel/install.d/50-depmod.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.4
  +depmod -a 5.16.0-1-amd64
  +/usr/lib/kernel/install.d/85-initrd.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.4
  +/usr/lib/kernel/install.d/90-loaderentry.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-4
  Installing /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  Creating /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf
  root at zoot2:~# find /tmp/br/
  /tmp/br/
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/linux
  /tmp/br/loader
  /tmp/br/loader/entries
  /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf

One then the other:
  root at zoot2:~# kernel-install -v add $(uname -r) /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.0-1-amd64
  Reading /usr/lib/kernel/install.conf…
  BOOT_ROOT=/tmp/br set via environment or install.conf
  machine-id d42f27f4670847aeae24b01bd283a4e0 acquired from /etc/machine-id
  Entry-token candidates: d42f27f4670847aeae24b01bd283a4e0 debian Default
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using BOOT_ROOT=/tmp/br, ENTRY_TOKEN=d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0 exists, using layout=bls
  Using ENTRY_DIR_ABS=/tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  Plugin files:
  /usr/lib/kernel/install.d/50-depmod.install
  /usr/lib/kernel/install.d/85-initrd.install
  /usr/lib/kernel/install.d/90-loaderentry.install
  +mkdir -v -p /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  +/usr/lib/kernel/install.d/50-depmod.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.4
  +depmod -a 5.16.0-1-amd64
  +/usr/lib/kernel/install.d/85-initrd.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-5.16.4
  +/usr/lib/kernel/install.d/90-loaderentry.install add 5.16.0-1-amd64 /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64 /boot/vmlinuz-5.16.0-1-amd64 /boot/initrd.img-4
  Installing /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  Creating /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf
  root at zoot2:~# find /tmp/br/
  /tmp/br/
  /tmp/br/loader
  /tmp/br/loader/entries
  /tmp/br/loader/entries/d42f27f4670847aeae24b01bd283a4e0-5.16.0-1-amd64.conf
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/linux
  /tmp/br/d42f27f4670847aeae24b01bd283a4e0/5.16.0-1-amd64/initrd

-- System Information:
Debian Release: 11.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-17-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd-boot depends on:
ii  libc6              2.31-13+deb11u4
pn  libsystemd-shared  <none>
pn  systemd-boot-efi   <none>

Versions of packages systemd-boot recommends:
ii  efibootmgr  17-1

systemd-boot suggests no packages.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20220921/ee1f4fcc/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list