grub2 cannot currently generate configuration without initrd

Bug #1640878 reported by Chris Glass
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
High
Chris Glass
Xenial
Fix Released
Undecided
Unassigned
grub2-signed (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

As it currently stands grub2 cannot create grub.cfg menu entries that do not use an initrd image if one is present but the user does not desire to use it.
Furthermore, root= entries only support UUID and LABEL, but neither is an option if booting the kernel without an initrd.

Suggestion:

Allow grub2 to create configuration files without an "initrd" line and passing PARTUUID as root= entry by adding configuration knobs.

[SRU Justification]
A lot of time is wasted across the many, many instances of Ubuntu loading initramfs when booting. It's a measurable savings of CPU time and electricity to skip loading an initramfs at boot if it's not required.

[Test case]
1. cp /boot/grub/grub.cfg /tmp/grub.cfg
2. install the grub packages from -proposed.
3. cmp /boot/grub/grub.cfg /tmp/grub.cfg || echo 'fail'
4. as root, configure /etc/default/grub to mount the root disk directly and bypass the initramfs:
  echo GRUB_DISABLE_INITRD=true >> /etc/default/grub
  root=$(awk </etc/fstab '$2 == "/" { print $1 }')
  case $root in
      LABEL=*|UUID=*)
          dev="-l -t $root"
          ;;
      *)
          dev=$root
          ;;
  esac
  partuuid=$(blkid -s PARTUUID -o value $dev)
  if [ -z "$partuuid" ]; then
      echo "Error: cannot get partuuid for $root."
  else
      echo GRUB_FORCE_PARTUUID=$partuuid >> /etc/default/grub
  fi
5. If a partuuid has been found, run update-grub. Note that this will only work if your root device is a partition on a GPT-formatted disk.
6. Check that /boot/grub/grub.cfg now contains entries that don't specify an initramfs, and do include root=PARTUUID=* on the kernel commandline.

[Regression potential]
This upload introduces no behavior changes unless the user updates /etc/default/grub to configure the use of the new feature, so there should be no regressions here. The SRU test case verifies that /boot/grub/grub.cfg remains unchanged with the new version.

Changed in grub2 (Ubuntu):
status: New → Triaged
importance: Undecided → High
assignee: nobody → Chris Glass (tribaal)
Revision history for this message
Chris Glass (tribaal) wrote :

cyphermox uploaded patched packages to ppa:cyphermox/grub .

Steps to assert this works are as follows:

- Boot a Yakkety EC2 image (https://console.aws.amazon.com/ec2/home?region=eu-central-1#launchAmi=ami-b87881d7)
- Login
- sudo apt-add-repository ppa:cyphermox/grub; sudo apt update; sudo apt-upgrade
- reboot
(assert the system comes back online with no modifications to the grub config)
- login again
- Get the PARTUUID for the image's disk: ls /dev/disk/by-partuuid/ (should be 6983c98a-01 on this particular image)
- Add "GRUB_FORCE_PARTUUID=6983c98a-01" to /etc/default/grub
- sudo update-grub
- reboot
(assert the system comes back online with a root=PARTUUID config)
- login again
- Add "GRUB_DISABLE_INITD=true" to /etc/default/grub.
- sudo update-grub
- reboot
(assert the system comes back online with root=PARTUUID and no initrd)

Currently the Xenial images we build don't expose partuuids (it's an artifact of CPC transitionning to a new build system, AFAIU).

Revision history for this message
Chris Glass (tribaal) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package grub2 - 2.02~beta3-3ubuntu1

---------------
grub2 (2.02~beta3-3ubuntu1) zesty; urgency=medium

  [ Colin Watson ]
  * Drop build-dependency on libxen-dev, unnecessary now that upstream has
    taken a copy of the necessary public headers.

  [ Chris Glass ]
  * debian/patches/support_initrd-less_boot.patch: Added knobs to allow
    non-initrd boot config. (LP: #1640878)

 -- Mathieu Trudel-Lapierre <email address hidden> Thu, 10 Nov 2016 14:30:45 -0500

Changed in grub2 (Ubuntu):
status: Triaged → Fix Released
Steve Langasek (vorlon)
description: updated
Steve Langasek (vorlon)
description: updated
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Chris, or anyone else affected,

Accepted grub2 into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/grub2/2.02~beta2-36ubuntu3.8 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in grub2 (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Steve Langasek (vorlon) wrote :

Hello Chris, or anyone else affected,

Accepted grub2-signed into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/grub2-signed/1.66.8 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in grub2-signed (Ubuntu):
status: New → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote :

Surprisingly, the partuuid stuff works even on dos partition tables, as of xenial. So I've successfully tested this, including a boot test!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package grub2 - 2.02~beta2-36ubuntu3.8

---------------
grub2 (2.02~beta2-36ubuntu3.8) xenial; urgency=medium

  * debian/patches/support_initrd-less_boot.patch: Added knobs to allow
    non-initrd boot config. Thanks Chris Glass! (LP: #1640878)

 -- Mathieu Trudel-Lapierre <email address hidden> Wed, 01 Mar 2017 12:36:16 -0500

Changed in grub2 (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for grub2 has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.