/etc/kernel/postinst.d/zz-update-grub triggers a grub update in lxc containers

Bug #1104463 reported by Stéphane Graber
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
Undecided
Colin Watson

Bug Description

Before anyone points it out, this is NOT a duplicate of bug 1060404, just a different but extremely similar problem :)

So I'm doing 12.10 => 13.04 desktop upgrade testing in a container. That means setting up a full dekstop 12.10 system, including grub and kernel, then dist-upgrading that to 13.04.

In the past, this used to fail because of bug 1060404 but now that it's been fixed, I'm getting into a different problem bcause of zz-update-grub calling update-grub, bypassing the check added to grub's postinst and causing a similar error:
===
Setting up linux-image-3.8.0-1-generic (3.8.0-1.5) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.8.0-1-generic /boot/vmlinuz-3.8.0-1-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.8.0-1-generic /boot/vmlinuz-3.8.0-1-generic
update-initramfs: Generating /boot/initrd.img-3.8.0-1-generic
cryptsetup: WARNING: could not determine root device from /etc/fstab
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.8.0-1-generic /boot/vmlinuz-3.8.0-1-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.8.0-1-generic /boot/vmlinuz-3.8.0-1-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.8.0-1-generic /boot/vmlinuz-3.8.0-1-generic
/usr/sbin/grub-probe: error: failed to get canonical path of /dev/mapper/castiana-home.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.8.0-1-generic.postinst line 1010.
dpkg: error processing linux-image-3.8.0-1-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of linux-image-extra-3.8.0-1-generic:
 linux-image-extra-3.8.0-1-generic depends on linux-image-3.8.0-1-generic; however:
  Package linux-image-3.8.0-1-generic is not configured yet.

dpkg: error processing linux-image-extra-3.8.0-1-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.8.0-1-generic; however:
  Package linux-image-3.8.0-1-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-3.8.0-1-generic; however:
  Package linux-image-extra-3.8.0-1-generic is not configured yet.

dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.8.0.1.14); however:No apport report written because MaxReports is reached already

  Package linux-image-generic is not configured yet.

dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 linux-image-3.8.0-1-generic
 linux-image-extra-3.8.0-1-generic
 linux-image-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
===

Proposed ways of fixing this as discussed in #ubuntu-devel include:
 - Make update-grub exit 0 if running-in-container returns 0
 - Patch just zz-update-grub with a similar check
 - Make the scripts check for the presence of the device and only then attempt to read/write to it (but limit that check to containers)

Revision history for this message
Adam Conrad (adconrad) wrote :

1. Patching zz-update-grub is almost certainly the wrong answer, as manual runs of update-grub(1) or, indeed, anything else that might call it that we've not noticed yet, will show exactly the same issue.

2. Exiting update-grub 0 on containers seems like a sane workaround, but probably long-term silly. And workarounds often end up as long-term tech debt.

3. Fixing it somehow magically in grub-probe sounds appealing, until we realise that there'd be no way for grub-probe to tell update-grub "well, I looked, but couldn't find anything useful for you" without either exiting non-zero (which is exactly what it does right now) or returning completely bogus info for you to later write to you grub config (ewww).

Given the above, the second option seems the simplest and sanest for now, with an enormous FIXME comment on it, mentioning that lxc is meant to get device namespaces "some day", and when that happens, this can probably be revisited. Thoughts?

Revision history for this message
Colin Watson (cjwatson) wrote :

"Skip update-grub in containers" is already in Debian/experimental/bzr for now, just not yet in raring. Sure, it's not really the best answer - but it'll do for the moment.

I actually prefer Adam's option one, because leaving manual calls to update-grub broken makes it clear that GRUB isn't really functional in this environment.

Revision history for this message
Colin Watson (cjwatson) wrote :

I fixed this as the other half of bug 1060404, hence the changelog.

grub2 (2.00-12ubuntu1) raring; urgency=low

  * Resynchronise with Debian. Remaining changes:
    - Adjust for default Ubuntu boot options ("quiet splash").
    - Default to hiding the menu; holding down Shift at boot will show it.
    - Set a monochromatic theme and an appropriate background for Ubuntu.
    - Apply Ubuntu GRUB Legacy changes to legacy update-grub script.
    - Remove "GNU/Linux" from default distributor string.
    - Add crashkernel option.
    - Bypass menu unless other OSes are installed or Shift is pressed.
    - Allow Shift to interrupt 'sleep --interruptible'.
    - Reduce visual clutter in normal mode.
    - Remove verbose messages printed before reading configuration.
    - Suppress kernel/initrd progress messages, except in recovery mode.
    - Show the boot menu if the previous boot failed.
    - Adjust upgrade version checks for Ubuntu.
    - Suppress "GRUB loading" message unless Shift is held down.
    - Check hardware support before using gfxpayload=keep.
    - Set vt.handoff=7 for smooth handoff to kernel graphical mode.
    - In recovery mode, add nomodeset to the Linux kernel arguments, and
      remove the 'set gfxpayload=keep' command.
    - Skip Windows os-prober entries on Wubi systems, and suppress the menu
      by default if those are the only other-OS entries.
    - Handle probing striped DM-RAID devices.
    - Disable cursor as early as possible in grub_main.
    - Apply patch from Fedora to add a "linuxefi" loader.
    - Automatically call linuxefi from linux when necessary.
    - On amd64, add raw-uefi custom upload tarballs for signing.
    - Generate configuration for signed UEFI kernels if available.
    - Install signed images if UEFI Secure Boot is enabled.
    - Output a menu entry for firmware setup on UEFI FastBoot systems.
    - Stop using the /usr/share/images/desktop-base/desktop-grub.png
      alternative as the fallback background.

 -- Colin Watson <email address hidden> Fri, 25 Jan 2013 00:36:50 +0000

grub2 (2.00-12) experimental; urgency=low

  * Silence output from running-in-container.
  * Also skip update-grub when running in a container (LP: #1060404).

 -- Colin Watson <email address hidden> Thu, 24 Jan 2013 23:21:48 +0000

Changed in grub2 (Ubuntu):
assignee: nobody → Colin Watson (cjwatson)
status: New → 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.