Skip to contentSkip to conversation

grub2 disk error with kvm

DISCUSSION Daniel Dehennin 2 participants 2 messages Aug 11, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I post a bug report here as asked by nyu on #grub.

=== IRC LOG ===
[13:32] <nyu> nebuchadnezzar: could you report the grub one first? the problem
is grub_biosdisk_get_diskinfo_standard() fails, but this call wasn't used when probing for drives (and I think it should be)
=== IRC LOG ===

I have a kvm machine featuring debian lenny (now upgraded to sid). It has only one disk configured, with one partition as LVM so I install grub2 1.96+20080724-7.

When booting I have the following error:

===
error: unknown drive hd15
Entering rescue mode...
===

This does not come from the configuration, I renamed grub.cfg and the same happens.

Nyu ask me to remove the grub_error call line 53:
grub_error (GRUB_ERR_BAD_DEVICE, "unknown device %s", name);

Then it gives me "error: no such disk".

In rescue mode:
- I can insmod normal and enter in normal mode to boot my system.
- ls gives me (lenny-var) (lenny-usr) (lenny-root) (lenny-boot) (hd0) (hd0,1) (hd1) (hd2)...(hd15)

The problem happens only when using the kvm -drive option:

sudo /usr/bin/kvm -M pc -m 256 -smp 1 -name lenny -monitor stdio \
    -boot c -drive file=/dev/hati/lenny,if=virtio,index=0,boot=on \
    -net nic,model=virtio,vlan=0 -net tap,vlan=0,ifname=vnet0 \
    -serial pty -parallel none -k fr

Replacing this by -hda makes it work:

sudo /usr/bin/kvm -M pc -m 256 -smp 1 -name lenny -monitor stdio \
    -boot c -hda dev/hati/lenny \
    -net nic,model=virtio,vlan=0 -net tap,vlan=0,ifname=vnet0 \
    -serial pty -parallel none -k fr

I provide the grub.cfg as attachement, I can provide lspci, dmesg or what ever you need.

Regards.

Signature · 3 lines
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates

# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
insmod lvm
set root=(lenny-usr)
search --fs-uuid --set b67ea215-b6ec-40cc-bfe8-56e1284a42c8 if font /share/grub/ascii.pff ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
terminal gfxterm
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_hurd ###
### END /etc/grub.d/10_hurd ###

### BEGIN /etc/grub.d/10_linux ###
insmod lvm
set root=(lenny-boot)
search --fs-uuid --set 5b03d02f-e69e-418d-8f03-b0eb4e3185de

menuentry "Debian GNU/Linux, linux 2.6.25-2-amd64" {
	linux	/vmlinuz-2.6.25-2-amd64 root=/dev/mapper/lenny-root ro  vga=0x318
	initrd	/initrd.img-2.6.25-2-amd64
}
menuentry "Debian GNU/Linux, linux 2.6.25-2-amd64 (single-user mode)" {
	linux	/vmlinuz-2.6.25-2-amd64 root=/dev/mapper/lenny-root ro single 
	initrd	/initrd.img-2.6.25-2-amd64
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries ### END /etc/grub.d/40_custom ###

#1 lore raw
Quoted 14 lines · Daniel Dehennin

Hello,

I post a bug report here as asked by nyu on #grub.

=== IRC LOG ===
[13:32] <nyu> nebuchadnezzar: could you report the grub one first? the problem
is grub_biosdisk_get_diskinfo_standard() fails, but this call wasn't used when probing for drives (and I think it should be)
=== IRC LOG ===

I have a kvm machine featuring debian lenny (now upgraded to sid). It has only one disk configured, with one partition as LVM so I install grub2 1.96+20080724-7.

Quoted 6 lines

When booting I have the following error:

===
error: unknown drive hd15
Entering rescue mode...
===

Hi,

Summary of the problem, based on what Daniel told me:

- grub_biosdisk_iterate() probes for hard drives by trying to read their first sector with grub_biosdisk_rw_standard(). In Daniel's setup, it finds 16 hard disks (the maximum), although only one exists.

- raid.mod (or anything else) sees the hard disks and tries to use them.

- grub_biosdisk_open() fails with "cannot get C/H/S values" because grub_biosdisk_get_diskinfo_standard() is not usable.

A possible solution would be to allow grub_biosdisk_get_diskinfo_standard() to fail as long as we have total_sectors, and let CHS values be set to 0 (AFAIK, as long as LBA works they're not essential). This wouldn't make the fake drives disappear (it's a KVM bug after all), but would prevent GRUB from aborting when this happens [1].

Another one would be to integrate grub_biosdisk_get_diskinfo_standard() as part of the probing routine in grub_biosdisk_iterate(), thus preventing the disks from appearing at all.

Or another one would be to do nothing, since it will be fixed in KVM sooner or later [2]. However, I think it's good if we can make GRUB behave more robustly, just in case we find similar bugs in propietary BIOSes.

[1] Then again, I think the last RAID patch from Felix would archieve the same effect. No reason we can't have both things though.

[2] Daniel, feel free to report this. You can point to this mail for their reference.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."