Package: grub2-common
Version: 2.14~git20250718.0e36779-2
Severity: important
X-Debbugs-Cc: [email protected]

Hello!

Starting with Linux kernel version 6.19.x, installing a linux-image-*
Debian package also pulls in the corresponding linux-base-* ,
linux-binary-* , and linux-modules-* Debian packages.

For instance, 'linux-image-6.19.8+deb14-amd64' depends on
'linux-base-6.19.8+deb14-amd64', 'linux-binary-6.19.8+deb14-amd64', and
'linux-modules-6.19.8+deb14-amd64'.

Please note the Linux kernel image is shipped in the linux-binary-*
Debian package:

    $ dpkg -S /boot/vmlinuz-6.19.8+deb14-amd64 
    linux-binary-6.19.8+deb14-amd64: /boot/vmlinuz-6.19.8+deb14-amd64

But '/etc/kernel/postrm.d/zz-update-grub' runs 'update-grub' after the
removal of a linux-image-* Debian package, and not after the removal
of a linux-binary-* Debian package.

This caused the following issue on more than one Debian testing box.

I upgraded the box and noticed that a new Linux kernel had migrated
to Debian testing.
The 'linux-image-amd64' meta-package was upgraded, pulling in
'linux-image-6.19.8+deb14-amd64', 'linux-base-6.19.8+deb14-amd64',
'linux-binary-6.19.8+deb14-amd64', and
'linux-modules-6.19.8+deb14-amd64'.

The installation of 'linux-image-6.19.8+deb14-amd64' followed the
installation of 'linux-binary-6.19.8+deb14-amd64'. After the
installation of 'linux-image-6.19.8+deb14-amd64', 'update-grub'
was run without any issue.

I rebooted the box and I checked that everything was reasonably
working.

Then I decided to get rid of one of the old kernels and chose
'linux-image-6.19.6+deb14+1-amd64':

    # aptitude --purge-unused purge linux-image-6.19.6+deb14+1-amd64 
    The following packages will be REMOVED:  
      linux-base-6.19.6+deb14+1-amd64{pu} linux-binary-6.19.6+deb14+1-amd64{pu} 
      linux-image-6.19.6+deb14+1-amd64{p} 
      linux-modules-6.19.6+deb14+1-amd64{pu} 
    0 packages upgraded, 0 newly installed, 4 to remove and 6 not upgraded.
    Need to get 0 B of archives. After unpacking 118 MB will be freed.
    Do you want to continue? [Y/n/?] 
    (Reading database… 65956 files and directories currently installed.)
    Removing linux-image-6.19.6+deb14+1-amd64 (6.19.6-2)…
    I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.18.15+deb14-amd64
    I: /initrd.img.old is now a symlink to boot/initrd.img-6.18.15+deb14-amd64
    /etc/kernel/postrm.d/initramfs-tools:
    update-initramfs: Deleting /boot/initrd.img-6.19.6+deb14+1-amd64
    /etc/kernel/postrm.d/zz-update-grub:
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-6.19.8+deb14-amd64
    Found initrd image: /boot/initrd.img-6.19.8+deb14-amd64
    Found linux image: /boot/vmlinuz-6.19.6+deb14+1-amd64
    Found linux image: /boot/vmlinuz-6.18.15+deb14-amd64
    Found initrd image: /boot/initrd.img-6.18.15+deb14-amd64
    Adding boot menu entry for UEFI Firmware Settings ...
    done
    Removing linux-binary-6.19.6+deb14+1-amd64 (6.19.6-2)…
    Removing linux-modules-6.19.6+deb14+1-amd64 (6.19.6-2)…
    Removing linux-base-6.19.6+deb14+1-amd64 (6.19.6-2)…
    dpkg: warning: while removing linux-base-6.19.6+deb14+1-amd64, directory 
'/usr/lib/modules/6.19.6+deb14+1-amd64' not empty so not removed
    (Reading database… 60710 files and directories currently installed.)
    Purging configuration files for linux-image-6.19.6+deb14+1-amd64 (6.19.6-2)…
                                             
    Current status: 12003 (-4) new.

As you can see, 'update-grub' ran too early (after the removal of
'linux-image-6.19.6+deb14+1-amd64'), when kernel image
'/boot/vmlinuz-6.19.6+deb14+1-amd64' was still present.
Immediately after that, 'linux-binary-6.19.6+deb14+1-amd64' was
removed, but 'update-grub' was not run again.

So I ended up with a situation where one of the GRUB menu entries
corresponded to a non-existent kernel image!

I had to manually run 'update-grub' again to fix this issue:

    # update-grub2
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-6.19.8+deb14-amd64
    Found initrd image: /boot/initrd.img-6.19.8+deb14-amd64
    Found linux image: /boot/vmlinuz-6.18.15+deb14-amd64
    Found initrd image: /boot/initrd.img-6.18.15+deb14-amd64
    Adding boot menu entry for UEFI Firmware Settings ...
    done


I think that '/etc/kernel/postrm.d/zz-update-grub' should kick in
after the removal of a linux-binary-* Debian package, as well as
after the removal of a linux-image-* Debian package (this last
one probably needs to be kept, in order to support the removal of
Linux kernel Debian packages older than version 6.19.x).


Please coordinate with the Debian Kernel Team and fix this behavior.

Thanks for your time and dedication!



-- System Information:
Debian Release: forky/sid
  APT prefers testing
  APT policy: (800, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.19.8+deb14-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages grub2-common depends on:
ii  gettext-base        0.23.2-1
ii  libc6               2.42-13
ii  libdevmapper1.02.1  2:1.02.205-2+b1
ii  libefiboot1t64      39-2+b1
ii  libefivar1t64       39-2+b1
ii  libfreetype6        2.14.2+dfsg-1
ii  libfuse3-4          3.18.1-1
ii  liblzma5            5.8.2-2

Versions of packages grub2-common recommends:
pn  os-prober  <none>

Versions of packages grub2-common suggests:
ii  console-setup  1.246
ii  desktop-base   14.0.0~pre3
pn  grub-emu       <none>
ii  mtools         4.0.49-1
pn  multiboot-doc  <none>
pn  xorriso        <none>

-- no debconf information

Reply via email to