[Bug 2150675] Re: /etc/default/grub found empty (0 bytes) after unattended upgrade on Ubuntu 26.04 while updating to kernel 7.0.0-15

Chris 2150675 at bugs.launchpad.net
Tue May 19 04:23:20 UTC 2026


The grub2 postinst uses `sed -i` (via `apply_conf_tweaks`) to apply
debconf settings to `/etc/default/grub`. `sed -i` works by creating a
temporary file, writing the modified content, and renaming it over the
original. If the system crashes or hangs during this write (as reported
— the machine became unresponsive during unattended-upgrade and required
a hard reboot), the temporary file may be empty or partially written,
and the rename replaces `/etc/default/grub` with this empty file.

This is consistent with the report: two identical NUCs running Ubuntu
26.04, an unattended-upgrade of kernel 7.0.0-14 to 7.0.0-15 involving
the grub2 package, one machine hung requiring a hard reboot, and
`/etc/default/grub` was found at 0 bytes afterwards while the other
machine upgraded fine.

## Proposed Fix (patch attached)

Add a safety check after the ucf merge in the postinst to detect and
recover from a truncated `/etc/default/grub`. If the file exists but is
empty, restore the distribution template from
`/usr/share/grub/default/grub` so the system remains bootable with
sensible defaults.

The check only fires when the file is already hosed — it has zero effect
on normal upgrades. The restored file provides working defaults (quiet
splash, standard timeout) and the user can re-customize afterwards. This
is strictly better than leaving the system with a 0-byte GRUB config
that can prevent booting or cause degraded behavior.

## Affected packages

All grub2 variants use the same ucf / apply_conf_tweaks pattern in their postinst:
- grub-efi-amd64
- grub-efi-arm64
- grub-efi-ia32
- grub-pc
- grub-ieee1275

** Attachment added: "launchpad-grub-empty-analysis.txt"
   https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2150675/+attachment/5971436/+files/launchpad-grub-empty-analysis.txt

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

Title:
  /etc/default/grub found empty (0 bytes) after unattended upgrade on
  Ubuntu 26.04 while updating to kernel 7.0.0-15

Status in grub2 package in Ubuntu:
  New

Bug description:
  System Context:
  I have two identical Intel 13th Gen i7 NUCs running Ubuntu 26.04.

  The Issue:
  Following an unattended-upgrade which updated the kernel from 7.0.0-14 to 7.0.0-15 involving the grub2 package, one machine became unresponsive/stuck, requiring a hard reboot. After rebooting, the system defaulted to a verbose boot (no splash screen) and showed a GRUB menu timeout.

  Upon inspection, /etc/default/grub on the affected machine was
  completely empty (0 bytes). The second identical machine updated
  successfully without wiping the file.

  Impact:
  Loss of critical boot parameters including quiet splash, zswap settings, and USB power management overrides (usbcore.autosuspend).

  Steps to Resolve:
  Manually restoring the content of /etc/default/grub from the healthy machine and running sudo update-grub resolved the issue.

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





More information about the foundations-bugs mailing list