Lucid Alpha 2 server iso install fails at bootloader in KVM

Bug #524434 reported by Boris Devouge on 2010-02-19
36
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Ubuntu
Undecided
Unassigned
Nominated for Lucid by Brian Knoll

Bug Description

Grub2 (grub-pc) fails when installing on a KVM virtual machine running virtio disks.

The disk appears as /dev/vda and it seems the installer tries against /dev/sda and /dev/hda, fails to find the disk, and proposes to continue without a bootloader.

Step to reproduce:

 - set up Ubuntu virtualization on a 64 bit KVM able machine (Karmic: apt-get install qemu-kvm virt-manager)
- download Lucid Alpha 2 srv 64 bit iso from http://cdimage.ubuntu.com/releases/lucid/alpha-2/
- install Lucid alpha 2 server in KVM and watch it fail over grub install

I have tried grub2, legacy grub and lilo and all failed. I could not complete Lucid Alpha 2 server 64 bit install

How reproducible:

Always, as long as VirtIO the disk interface on the guest (disk is presented as /dev/vda)

Changed in ubuntu:
status: New → Confirmed
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better. Can you please provide us with the options you ran kvm with?

I am also resetting Status to Incomplete -- simply changing Status to Confirmed without explanation is not enough evidence.

Changed in ubuntu:
status: Confirmed → Incomplete
pakraticus (pakraticus) wrote :

kvm command line as generated by libvirt-bin

/usr/bin/kvm -S -M pc-0.11 -enable-kvm -m 1024 -smp 2,sockets=2,cores=1,threads=1 -name BT -uuid 7e4c5cc4-f077-e52e-6d2d-f865637e87df -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/BT.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot cd -device lsi,id=scsi0,bus=pci.0,addr=0x6 -drive file=/local/vimages/isos/ubuntu/lucid-alternate-amd64.iso,if=none,media=cdrom,id=drive-ide0-1-0 -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/dev/greasy-vg/bt,if=none,id=drive-virtio-disk0,boot=on,format=raw -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0 -device e1000,vlan=0,id=net0,mac=54:52:00:33:9c:2d,bus=pci.0,addr=0x4 -net tap,fd=46,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k en-us -vga cirrus -device ES1370,id=sound0,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

Some history and quirks.

1) This system has had the virtual disk swapped to SCSI and back to virtio.

2) grub-pc postinst fails after a switch from SCSI to virtio with cannot find /dev/disk/by-id/....
(There is *NO* /dev/disk/by-id with virtio)

3) After purging grub-pc and reinstalling it, the postinst can no longer find a disk where grub should be installed.

4) grub-install --recheck /dev/vda works just fine

Thoughts.
1) udev persistent storage rules probably need to match the [vs]d*[!0-9] wildmat instead of sd*[!0-9].
2) Until udev is fixed, it would be pleasant if grub-pc.postinst would fallback to /dev/disk/by-uuid.
I think this does it.
available_ids()
{
  local id path diskby

  if [ "$cached_available_ids" ]; then
    echo "$cached_available_ids"
    return
  fi

  for diskby in /dev/disk/by-id /dev/disk/by-uuid; do
    [ -d "$diskby" ] && break
  done
  cached_available_ids="$(
    for path in "$diskby"/* ; do
      [ -e "$path" ] || continue
      printf '%s %s\n' "$path" "$(readlink -f "$path")"
    done | sort -k2 -s -u | cut -d' ' -f1
  )"
  echo "$cached_available_ids"
}
3) Yes, I know testing is a pain, but it's probably worth checking that install works with kvm with all three possible ways of providing disk.

zoolook (nbensa) wrote :

Me too does work here?

Changing from virtio to sda/hda does workaround this problem, but a fix is needed asap.

zoolook (nbensa) wrote :

BTW, note that this bug is also present in the released Lucid Linx.

It would be nice if the available_ids() supplied by pakraticus above was an actual grub-pc patch.

The available_ids() as a patch against grub-pc 1.98-1ubuntu6

$ diff -u /var/lib/dpkg/info/grub-pc.postinst .
--- /var/lib/dpkg/info/grub-pc.postinst 2010-04-29 04:24:48.000000000 -0400
+++ ./grub-pc.postinst 2010-05-05 15:43:27.491704375 -0400
@@ -19,16 +19,18 @@
 cached_available_ids=
 available_ids()
 {
- local id path
+ local id path diskby

   if [ "$cached_available_ids" ]; then
     echo "$cached_available_ids"
     return
   fi

- [ -d /dev/disk/by-id ] || return
+ for diskby in /dev/disk/by-id /dev/disk/by-uuid; do
+ [ -d "$diskby" ] && break
+ done
   cached_available_ids="$(
- for path in /dev/disk/by-id/*; do
+ for path in "$diskby"/* ; do
       [ -e "$path" ] || continue
       printf '%s %s\n' "$path" "$(readlink -f "$path")"
     done | sort -k2 -s -u | cut -d' ' -f1

The available_ids() doesn't help me because my system's grub is installed in /dev/vda not /dev/vda1 and:

$ ls -l /dev/disk/by-uuid/*
lrwxrwxrwx 1 root root 10 2010-05-05 10:11 /dev/disk/by-uuid/0458c062-1d4e-4134-8dfa-b90c217fd80b -> ../../vda1

When I changed the grub-pc postinstall script like this the grub-pc package configured on lucid with virtio disk:

$ diff -u grub-pc.postinst.DIST grub-pc.postinst
--- grub-pc.postinst.DIST 2010-05-05 15:37:19.000000000 -0400
+++ grub-pc.postinst 2010-05-10 09:39:12.361704621 -0400
@@ -19,16 +19,18 @@
 cached_available_ids=
 available_ids()
 {
- local id path
+ local id path diskby

   if [ "$cached_available_ids" ]; then
     echo "$cached_available_ids"
     return
   fi

- [ -d /dev/disk/by-id ] || return
+ for diskby in /dev/disk/by-id /dev/disk/by-uuid; do
+ [ -d "$diskby" ] && break
+ done
   cached_available_ids="$(
- for path in /dev/disk/by-id/*; do
+ for path in "$diskby"/* ; do
       [ -e "$path" ] || continue
       printf '%s %s\n' "$path" "$(readlink -f "$path")"
     done | sort -k2 -s -u | cut -d' ' -f1
@@ -45,6 +47,10 @@
       echo "$id"
       return 0
     fi
+ if [ "$(readlink -f "$id" | sed -e 's/.$//')" = "$(readlink -f "$1")" ]; then
+ echo "$id"
+ return 0
+ fi
   done
   return 1
 }

Same as a patch file attachment.

I noticed that if I build the KVM guest with virtio disk completely in LVM and use grub2 to boot from LVM this issue is avoided.

Note that you can't use linux-image-virtual when doing this since it lacks the drivers for DM (and it's not just modules either.)

Jan Jonas (jj-learnbit) wrote :

Same problem here with an virtualized Ubuntu 10.04 under XenServer 5.6: The grub installer does not find the virtual hard disks /dev/xvdX.

Trying to install grub results in:

Setting up grub-pc (1.98-1ubuntu6) ...
dpkg: error processing grub-pc (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
grub-pc
E: Sub-process /usr/bin/dpkg returned an error code (1)

After using nutznboltz's patch file everything works fine.

*bump* (to prevent automatic expiration)

zoolook (nbensa) wrote :

undecided?
incomplete?
unassigned?

Time to shop for new distro for my servers...

--- On Sat, 7/10/10, zoolook <email address hidden> wrote:

> From: zoolook <email address hidden>
> Subject: [Bug 524434] Re: Lucid Alpha 2 server iso install fails at bootloader in KVM
> To: <email address hidden>
> Date: Saturday, July 10, 2010, 10:26 PM
>
> undecided?
> incomplete?
> unassigned?
>
> Time to shop for new distro for my servers...

Some of this is due to https://launchpad.net/~bdevouge not filing the bug against grub2. He should have run "ubuntu-bug grub-pc" to start the reporting process. I went ahead and submitted a duplicate bug but starting with "ubuntu-bug grub-pc".

The moral of the story is to use the ubuntu-bug program to report bugs.
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/603621

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers