fix grub-install to not write modules to /boot before we know we have a valid disk target

Bug #2043995 reported by Steve Langasek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
High
Unassigned
Noble
Fix Released
High
Unassigned

Bug Description

grub2 2.04-1ubuntu26.2 in 2020 introduced a workaround in focal for the fact that grub2 would write updated modules to /boot/grub, and only afterwards check that it had a valid disk target for installation of the first stage bootloader, with the result that if the debconf config for grub was outdated and points at a device that no longer exists, and there is ABI skew between the 1st/2nd stage bootloader and the grub modules from the new package, the system becomes unbootable because it is unable to load modules from the /boot filesystem, and rollback is not possible (LP: #1889556).

This was supposed to be a workaround, but the work was never done to fix grub-install behavior to avoid this detectable and avoidable failure.

We need grub-install to validate the target disk, and if it is unavailable, abort BEFORE updating /boot/grub with incompatible contents.

Once this is done, the postinst hack that skips grub-install for grub-pc should be dropped.

Steve Langasek (vorlon)
tags: added: foundations-todo
Changed in grub2 (Ubuntu):
importance: Undecided → High
Changed in grub2 (Ubuntu Noble):
milestone: none → ubuntu-24.04-beta
Revision history for this message
Julian Andres Klode (juliank) wrote :

I think we need to have rollback either way, if we have a valid target disk but then fail to write the sectors or we fail halfway building core.mod or something we'd want to try to restore some backup of what we had before.

Revision history for this message
Mate Kukri (mkukri) wrote :

Since the workaround was introduced, grub-install gained support for the rollback /boot if things go wrong, so theoretically we could re-enable grub-install now.

Changed in grub2 (Ubuntu Noble):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package grub2 - 2.12~rc1-12ubuntu3

---------------
grub2 (2.12~rc1-12ubuntu3) noble; urgency=medium

  * d/p/delay-copying-to-grubdir.patch: Improve grub-install robustness by
    delaying the update of /boot after install device validation
  * Remove workaround for LP: 1889556 (LP: #2043995)
    - Was not needed since /boot rollback was introduced upstream
    - Patch above ensures that this will not reoccur even if rollback fails

 -- Mate Kukri <email address hidden> Tue, 21 Nov 2023 15:35:55 +0000

Changed in grub2 (Ubuntu Noble):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.