cloud-init does not run grub on PV Xen and KVM has issues

Bug #961240 reported by Alex Bligh
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Triaged
Low
Unassigned

Bug Description

On paravirtualised Xen, cloud-init will not rerun grub. KVM may also have issues.

The problem is at:
 http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/CloudConfig/cc_grub_dpkg.py
line 47.

The 'if' condition at line 36 handles the case where a block major device is presented as /dev/sda1 (or /dev/xvda1), which it detects by the absence of /dev/sda or /dev/xvda (as appropriate). This takes into account the odd EC2 way of doing things.

The else condition at line 42 is run in a non-EC2 mode, where either the block major itself is a filing system, or the block major contains a partition table. The for loop at line 47 then runs through 'all' the first block minor devices (i.e. first partitions), then (if it fails to find any) the block majors.

The first issue is that running on Xen on HVM with PV drivers, the emulated device is PCI unplugged early in the boot sequence, so there is no /dev/sda or /dev/sda1, just /dev/xvda and /dev/xvda1. Line 47 will thus not pick this up. /dev/xvda and /dev/xvda1 should thus be added to this line.

The second issue is that I /think/ /dev/vda should be listed before /dev/sda, and /dev/vda1 before /dev/sda1. This is because running on kvm, both devices will appear under some circumstances (e.g. where the cloud provider cannot determine whether the OS has PV drivers or not so provides both emulated and PV drevice), and I think it's desirable that grub thinks it is installing on the virtual device /dev/vda1.

IE I think the line should be:
  for dev in ("/dev/xvda", "/dev/vda", "/dev/sda", "/dev/xvda1", "/dev/vda1", "/dev/sda1"):

Complete untested patch attached.

Tags: patch
Revision history for this message
Alex Bligh (ubuntu-alex-org) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "untested patch to fix loop over devices" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Scott Moser (smoser) wrote :

I think some things might be good to write down here.
 * the reason for checking of /dev/sda1 and /dev/sda (and xvda1 and xvda) is that on EC2 these
   devices do not both exist. Ie, the root device is actually a block device (not a partition) but is named xvda1 or svda1
 * the purpose of this code is to tell grub where to install (otherwise, on upgrade of grub, it would complain that the last time it ran it installed to a device that is now not present, and bother the user).
 * if this fails, the result is not failure to boot, but rather a prompt on grub upgrade.

First issue:
 * I think you're right that xvda and xvda1 should be added there.

Second issue:
 * I think that this doesn't matter. grub will just check/insist that the devices it thinks should be installed to are there.

More testing is needed here, the grub code is complex, and I'm weary of changing this because i haven't actually seen or reproduced an issue, and my mind is fuzzy.

for reference:
  bug 623609
  bug 752361

James Page (james-page)
Changed in cloud-init (Ubuntu):
importance: Undecided → Low
Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
status: New → Triaged
Revision history for this message
Lisa Simpson (lisa-p) wrote :

I am experiencing this on 16.04 and 18.04 when using a Xen hypervisor. This isn't just happening on 1 or 2 either.

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.