Here are my notes from filing a duplicate issue (with just dracut,
initramfs-tools is purged), the missing step in bdrung's comment is
kernel-install.

This issue involves systemd (the kernel-install command, the
/usr/lib/kernel/install.d/55-initrd.install script that copies
/boot/initrd.img-$KERNEL_VERSION from /boot to /boot/efi), third-party
scripts hooking into kernel-install like dracut-core's
/usr/lib/kernel/install.d/50-dracut.install, and dracut, which provides
/etc/kernel/postinst.d/dracut which is run by kernel-image maintainer
scripts like /var/lib/dpkg/info/linux-image-6.14.0-15-generic.postinst.

Steps (thanks to execsnoop on apt reinstall linux-image-$KERNEL_VERSION):
- /etc/kernel/postinst.d/dracut generates /boot/initrd.img-$KERNEL_VERSION
- /etc/kernel/postinst.d/initramfs-tools calls update-initramfs (shipped by 
either dracut or initramfs-tools)
  - /usr/sbin/update-initramfs calls /etc/initramfs/post-update.d/systemd-boot, 
which calls kernel-install
- /etc/kernel/postinst.d/zz-systemd-boot also calls kernel-install if neither 
dracut nor initramfs-tools is installed
- kernel-install then runs:
  - /usr/lib/kernel/install.d/50-dracut.install from dracut-core, which runs 
dracut again, generates /boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd
  - /usr/lib/kernel/install.d/55-initrd.install from systemd which copies 
/boot/initrd.img-$KERNEL_VERSION to 
/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd.img-$KERNEL_VERSION

Which is how the EFI system partition ends up with duplicate initrds for every 
kernel version.
ESP space is limited and hard to grow so this is problematic.

On 25.04 plucky, it is possible to have dracut-core installed, dracut
and initramfs-tools both purged (purge removes left-over hooks from
/etc), in which case dracut-core will still generate an
/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd,
/boot/initrd.img-$KERNEL_VERSION won't be generated for newly installed
kernels, and the duplication is avoided.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2100296

Title:
  Double initrd in /efi/<machine-id>/<kver>/ with systemd-boot

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dracut/+bug/2100296/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to