Package: grub-pc
Version: 2.12-9+deb13u2
Severity: normal

Dear Maintainer,

After several grub-pc and kernel package upgrades on a Debian 13 (trixie)
system, the GRUB stages embedded on disk (MBR boot.img + core.img in the
post-MBR gap) drifted out of sync with the modules under /boot/grub/i386-pc/ and
the regenerated /boot/grub/grub.cfg. The visible symptom was that GRUB
consistently booted an older installed kernel (6.12.48) instead of the current
default (6.12.90), across multiple reboots, despite /boot/grub/grub.cfg
correctly listing 6.12.90 as the default entry.

A second tell-tale symptom: next_entry=0 in /boot/grub/grubenv was never cleared
on boot, even though grub.cfg contains the standard set default="${next_entry}";
set next_entry=; save_env next_entry block. This indicates the running GRUB was
not executing (or not successfully writing back) the current grub.cfg. 

Steps to reproduce:

1. Install Debian on a BIOS/MBR system (in my case via Hetzner installimage,
which runs grub-install once at provisioning). 
2. Over time, allow normal apt upgrade runs to upgrade grub-pc, grub-common,
grub-pc-bin, and install new kernels. update-grub runs as part of these
upgrades; grub-install does not.
3. Reboot. GRUB picks an older kernel than the one listed as default in
/boot/grub/grub.cfg.

Workaround:

Re-running grub-install /dev/sda followed by update-grub resyncs the on-disk
core.img with the current modules and config. After this, reboots correctly
select the newest kernel and grubenv writes work again.

Expected behavior:

Either (a) grub-pc package upgrades should re-run grub-install on the configured
target device(s) when the on-disk core.img would otherwise become incompatible
with the upgraded modules, or (b) the package should detect this drift and warn
the administrator that grub-install needs to be re-run manually. The current
silent-failure mode is hard to diagnose, especially on remote/headless systems
where the GRUB menu cannot be observed.



-- Package-specific info:

*********************** BEGIN /proc/mounts
/dev/mapper/puss--vg-root / ext4 rw,relatime,errors=remount-ro 0 0
/dev/sda1 /boot ext2 rw,relatime 0 0
*********************** END /proc/mounts

*********************** BEGIN /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod lvm
insmod ext2
set 
root='lvmid/HBW541-0C9Z-0zG1-5aQt-LLjO-Q0k3-vclhCy/dYcMtZ-SAlu-jN5D-e3s9-7izO-ZkuC-4rDBlM'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root 
--hint='lvmid/HBW541-0C9Z-0zG1-5aQt-LLjO-Q0k3-vclhCy/dYcMtZ-SAlu-jN5D-e3s9-7izO-ZkuC-4rDBlM'
  4b9a5e9c-9288-4aea-9713-0793ea5ab9a7
else
  search --no-floppy --fs-uuid --set=root 4b9a5e9c-9288-4aea-9713-0793ea5ab9a7
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=5
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=5
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
        set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu 
--class os $menuentry_id_option 
'gnulinux-simple-4b9a5e9c-9288-4aea-9713-0793ea5ab9a7' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 
--hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
        else
          search --no-floppy --fs-uuid --set=root 
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
        fi
        echo    'Loading Linux 6.12.90+deb13.1-amd64 ...'
        linux   /vmlinuz-6.12.90+deb13.1-amd64 root=/dev/mapper/puss--vg-root 
ro  quiet
        echo    'Loading initial ramdisk ...'
        initrd  /initrd.img-6.12.90+deb13.1-amd64
}
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 
'gnulinux-advanced-4b9a5e9c-9288-4aea-9713-0793ea5ab9a7' {
        menuentry 'Debian GNU/Linux, with Linux 6.12.90+deb13.1-amd64' --class 
debian --class gnu-linux --class gnu --class os $menuentry_id_option 
'gnulinux-6.12.90+deb13.1-amd64-advanced-4b9a5e9c-9288-4aea-9713-0793ea5ab9a7' {
                load_video
                insmod gzio
                if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; 
fi
                insmod part_msdos
                insmod ext2
                set root='hd0,msdos1'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root 
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
                else
                  search --no-floppy --fs-uuid --set=root 
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
                fi
                echo    'Loading Linux 6.12.90+deb13.1-amd64 ...'
                linux   /vmlinuz-6.12.90+deb13.1-amd64 
root=/dev/mapper/puss--vg-root ro  quiet
                echo    'Loading initial ramdisk ...'
                initrd  /initrd.img-6.12.90+deb13.1-amd64
        }
        menuentry 'Debian GNU/Linux, with Linux 6.12.90+deb13.1-amd64 (recovery 
mode)' --class debian --class gnu-linux --class gnu --class os 
$menuentry_id_option 
'gnulinux-6.12.90+deb13.1-amd64-recovery-4b9a5e9c-9288-4aea-9713-0793ea5ab9a7' {
                load_video
                insmod gzio
                if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; 
fi
                insmod part_msdos
                insmod ext2
                set root='hd0,msdos1'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root 
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
                else
                  search --no-floppy --fs-uuid --set=root 
bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c
                fi
                echo    'Loading Linux 6.12.90+deb13.1-amd64 ...'
                linux   /vmlinuz-6.12.90+deb13.1-amd64 
root=/dev/mapper/puss--vg-root ro single dis_ucode_ldr 
                echo    'Loading initial ramdisk ...'
                initrd  /initrd.img-6.12.90+deb13.1-amd64
        }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
  insmod bli
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
if [ "$grub_platform" = "efi" ]; then
        fwsetup --is-supported
        if [ "$?" = 0 ]; then
                menuentry 'UEFI Firmware Settings' $menuentry_id_option 
'uefi-firmware' {
                        fwsetup
                }
        fi
fi
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###
*********************** END /boot/grub/grub.cfg

*********************** BEGIN /proc/mdstat
cat: /proc/mdstat: No such file or directory
*********************** END /proc/mdstat

*********************** BEGIN /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 May 29 12:52 ata-QEMU_DVD-ROM_QM00003 -> ../../sr0
lrwxrwxrwx 1 root root 10 May 29 12:52 dm-name-puss--vg-root -> ../../dm-0
lrwxrwxrwx 1 root root 10 May 29 12:52 dm-name-puss--vg-swap_1 -> ../../dm-1
lrwxrwxrwx 1 root root 10 May 29 12:52 
dm-uuid-LVM-HBW5410C9Z0zG15aQtLLjOQ0k3vclhCyAbnz2AfQMQNlrxMura6dQEDLJgRpoQah -> 
../../dm-1
lrwxrwxrwx 1 root root 10 May 29 12:52 
dm-uuid-LVM-HBW5410C9Z0zG15aQtLLjOQ0k3vclhCydYcMtZSAlujN5De3s97izOZkuC4rDBlM -> 
../../dm-0
lrwxrwxrwx 1 root root 10 May 29 12:52 
lvm-pv-uuid-Y3ZtJV-WdpX-gOXm-cxev-AD6i-ABJ1-KMJKp3 -> ../../sda5
lrwxrwxrwx 1 root root  9 May 29 12:52 scsi-0QEMU_QEMU_HARDDISK_38212 -> 
../../sda
lrwxrwxrwx 1 root root 10 May 29 12:52 scsi-0QEMU_QEMU_HARDDISK_38212-part1 -> 
../../sda1
lrwxrwxrwx 1 root root 10 May 29 12:52 scsi-0QEMU_QEMU_HARDDISK_38212-part2 -> 
../../sda2
lrwxrwxrwx 1 root root 10 May 29 12:52 scsi-0QEMU_QEMU_HARDDISK_38212-part5 -> 
../../sda5
*********************** END /dev/disk/by-id

*********************** BEGIN /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 May 29 12:52 4b9a5e9c-9288-4aea-9713-0793ea5ab9a7 -> 
../../dm-0
lrwxrwxrwx 1 root root 10 May 29 12:52 bf89d3fe-cd9e-4465-bee8-9d6f9a27cd0c -> 
../../sda1
lrwxrwxrwx 1 root root 10 May 29 12:52 f4feec06-ac9f-4b85-abbd-87422875d885 -> 
../../dm-1
*********************** END /dev/disk/by-uuid

-- System Information:
Debian Release: 13.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

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

Versions of packages grub-pc depends on:
ii  debconf [debconf-2.0]  1.5.91
ii  grub-common            2.12-9+deb13u2
ii  grub-pc-bin            2.12-9+deb13u2
ii  grub2-common           2.12-9+deb13u2
ii  ucf                    3.0052

grub-pc recommends no packages.

grub-pc suggests no packages.

-- debconf information:
  grub2/kfreebsd_cmdline:
  grub2/enable_os_prober: false
  grub-pc/postrm_purge_boot_grub: false
  grub-pc/kopt_extracted: false
* grub2/linux_cmdline:
  grub-pc/install_devices_failed: false
  grub-pc/timeout: 5
  grub-pc/install_devices_empty: false
  grub-pc/partition_description:
  grub-pc/hidden_timeout: false
  grub2/force_efi_extra_removable: false
  grub-pc/mixed_legacy_and_grub2: true
  grub2/update_nvram: true
  grub-pc/install_devices_failed_upgrade: true
  grub2/device_map_regenerated:
* grub-pc/install_devices: /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_38212-part1
  grub-pc/chainload_from_menu.lst: true
* grub2/linux_cmdline_default: quiet
* grub-pc/install_devices_disks_changed: 
/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_38212-part1
  grub-pc/disk_description:
  grub2/kfreebsd_cmdline_default: quiet

Reply via email to