Public bug reported: AFFECTED RELEASES: 24.04 LTS (2.12-1ubuntu7.3) and 26.04 LTS (2.14-2ubuntu2.1), reproduced. 25.10 (2.14~git20250718.0e36779-1ubuntu4), reproduced, now end of life. Development (2.14-2ubuntu3) has the same code; not reproduced there.
This is a known race class, not a new discovery. We reproduced it independently on stock Ubuntu cloud images and measured it. GNU GRUB has fixed it upstream; the Ubuntu packages we checked do not carry the fix. Please backport it. grub-mkconfig takes no lock, and every run uses the same temporary file, grub.cfg.new. When two runs overlap, one can remove that file while the other is about to copy it over grub.cfg, which the shell has already truncated. grub.cfg is left empty or without boot entries. UPSTREAM FIX GNU GRUB commit 4f07dd265eef0c9f542c68f990904a9241460ce1, "grub-mkconfig: avoid temp-file races in concurrent runs", merged 2026-10-27 (merge request !216), on master; no release tag contains it yet (newest is grub-2.16): https://gitlab.freedesktop.org/gnu-grub/grub/-/commit/4f07dd265eef0c9f542c68f990904a9241460ce1 IS IT IN UBUNTU? No, as checked on 2026-11-30. We read the source of 2.12-1ubuntu7 and 2.12-1ubuntu7.3 (24.04), 2.14~git20250718.0e36779-1ubuntu4 (25.10), 2.14-2ubuntu2 and 2.14-2ubuntu2.1 (26.04), and the patches of 2.14-2ubuntu3 (development). Each still uses the fixed ${grub_cfg}.new path. THE SAME CLASS ELSEWHERE - grub-btrfs #288: "cannot open '/boot/grub/grub.cfg.new': No such file or directory" with a second caller running. https://github.com/Antynea/grub-btrfs/issues/288 - TrueNAS (truenas/middleware commit a50f509, May 2026): two boot listeners ran grub-mkconfig concurrently and raced on the config. https://github.com/truenas/middleware/commit/a50f509e0595b54010f88ee9016ecb75077a237b - Related only: LP #396381 is about update-grub being run more than once during one upgrade. It does not report a race. OUR REPRODUCTION (x86-64 stock cloud images, only cloud-init configuration, QEMU/KVM) A trial = two update-grub runs, then check that grub.cfg parses and still has boot entries. 20 trials each (two at once / one after the other / two at once, each under one flock): - 24.04.5, grub2-common 2.12-1ubuntu7.3: 5 of 20 unusable / 0 of 20 / 0 of 20 - 26.04.1, grub2-common 2.14-2ubuntu2.1: 5 of 20 unusable / 0 of 20 / 0 of 20 - 25.10, grub2-common 2.14~git20250718.0e36779-1ubuntu4: two at once 4 of 20, 2 of 20 and 2 of 20 unusable in three runs; one after the other 0 of 20 (two runs); under flock 0 of 20 (one run) 100 trials each, stock against the upstream change (applied by hand to the installed /usr/sbin/grub-mkconfig, not a rebuilt package), fresh VM per release: - 24.04, stock: 28 of 100 unusable; in 69 trials a run exited non-zero - 24.04, with the change: 0 of 100; 0 non-zero exits - 26.04, stock: 9 of 100 unusable; in 29 trials a run exited non-zero - 26.04, with the change: 0 of 100; 0 non-zero exits Consequence: on an untouched 25.10 image we looped until the race left a 0-byte grub.cfg and rebooted. The machine did not come back; the console showed a bare "grub>" prompt. This was done once; it is not a failure rate. Counts vary from run to run. Not tested: UEFI boot, other architectures, other distributions. One behaviour change to weigh in a stable update: for a grub.cfg that is not a symlink, the upstream change replaces the file by mv, where the old script rewrote it in place. STEPS TO REPRODUCE ONLY ON A THROWAWAY VM: this can leave the machine unable to boot. As root: good() { grub-script-check /boot/grub/grub.cfg && grep -q '^menuentry\|^[[:space:]]*linux' /boot/grub/grub.cfg; } bad=0; for i in $(seq 20); do update-grub >/dev/null 2>&1 update-grub >/dev/null 2>&1 & update-grub >/dev/null 2>&1; wait good || bad=$((bad+1)); done update-grub >/dev/null 2>&1; good && echo "restored" ; echo "unusable after $bad of 20 trials" Check that it prints "restored" before rebooting. For the comparisons, run the two update-grub calls one after the other, or put each under the same lock (flock /run/grub-test.lock update-grub). WHEN THIS CAN HAPPEN Package triggers run under the dpkg lock, so two package operations do not collide this way. It needs a second caller: an administrator or a management tool running update-grub while a package upgrade is regenerating the file. How often that happens in the field is not known. REQUEST Please backport 4f07dd265eef to the grub2 packages of the supported releases (24.04 LTS and 26.04 LTS) and include it in the development release. Reported by MinakiLabs. ** Affects: grub2 (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2178455 Title: Please backport upstream 4f07dd26: concurrent update-grub runs can leave grub.cfg without boot entries To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2178455/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
