Public bug reported:

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):
- /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, 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.

** Affects: dracut (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: systemd (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: systemd-boot

** Description changed:

  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):
  - /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 install-kernel
+   - /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
+   - /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, 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/2111811

Title:
  Duplicate initrds in /boot/efi partition with dracut

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


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

Reply via email to