Bug#525879: cannot install itself to block devices, tries to be too smart

martin f krafft madduck at debian.org
Mon Apr 27 16:30:43 UTC 2009


Package: grub-pc
Version: 1.96+20080724-16
Severity: normal

I want to use /dev/mapper/khyber-test1--root as the
base device for a KVM instance. I don't need partitions and just
want to use the "drive" directly. Thus, I tried to install grub2 on
it, but have failed miserably, due to grub2 trying to be so smart
that it won't do the things I ask it to.

I understand that there's something going on about LVM and that
grub-install stops at the abstraction layer and tries to access the
drives below, but even with grub-setup, I am not arriving.

Anyway, first things first:

-- Setup
# mount /dev/mapper/khyber-test1--root /mnt2

-- Try grub-install
# grub-install --root-directory=/mnt2 /dev/mapper/khyber-test1--root
grub-probe: error: no mapping exists for `khyber-test1-root'
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.

> This should use /mnt2/boot/grub/device.map, but even if I add
> a mapping to (hd0) to /dev/mapper/khyber-test1--root
> to that file, the error stays the same. I also tried to modify
> /boot/grub/device.map (the SYSTEM's device.map), but without any
> change in result.

I think the problem is that grub-install has been made to be
super-convenient and finds an LVM volume, tries to find the
components, and might even find /dev/md0 and /dev/sd[abcd] of the
host system, but those are obviously very wrong in the context of
the virtual machine.

I thus abandoned this path and turned to grub-setup, which is more
bare-bones than grub-install:

-- Create a core.img file
# grub-mkimage -d /mnt2/usr/lib/grub/i386-pc -p /mnt2/boot/grub -o /mnt2/boot/grub/core.img -v
grub-mkimage: info: getting the size of /mnt2/usr/lib/grub/i386-pc/kernel.img
grub-mkimage: info: the total module size is 0xc
grub-mkimage: info: reading /mnt2/usr/lib/grub/i386-pc/kernel.img
grub-mkimage: info: getting the size of /mnt2/usr/lib/grub/i386-pc/kernel.img
grub-mkimage: info: kernel_img=0x19ce300, kernel_size=0x7910
grub-mkimage: info: the core size is 0x45b9
grub-mkimage: info: getting the size of /mnt2/usr/lib/grub/i386-pc/diskboot.img
grub-mkimage: info: reading /mnt2/usr/lib/grub/i386-pc/diskboot.img
grub-mkimage: info: getting the size of /mnt2/usr/lib/grub/i386-pc/diskboot.img
grub-mkimage: info: writing 0x200 bytes
grub-mkimage: info: the first module address is 0x0
grub-mkimage: info: writing 0x45b9 bytes

-- Create device.map
# cat <<_eof > /mnt2/boot/grub/device.map
(hd0)   /dev/mapper/khyber-test1--root
_eof

-- Use grub-setup
# grub-setup -d /mnt2/boot/grub -v '(hd0)'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb1'
grub-setup: info: opening the device `/dev/sdb1'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc1'
grub-setup: info: opening the device `/dev/sdc1'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd1'
grub-setup: info: opening the device `/dev/sdd1'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: opening the device `/dev/sda1'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: opening the device `/dev/sda2'
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb1'
grub-setup: info: opening the device `/dev/sdb1'
grub-setup: info: opening the device `/dev/sdb1'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: opening the device `/dev/sdb2'
grub-setup: info: the size of hd1 is 1953525168
grub-setup: info: opening the device `/dev/sdb'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc1'
grub-setup: info: opening the device `/dev/sdc1'
grub-setup: info: opening the device `/dev/sdc1'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: opening the device `/dev/sdc2'
grub-setup: info: the size of hd2 is 1953525168
grub-setup: info: opening the device `/dev/sdc'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd1'
grub-setup: info: opening the device `/dev/sdd1'
grub-setup: info: opening the device `/dev/sdd1'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: opening the device `/dev/sdd2'
grub-setup: info: the size of hd3 is 1953525168
grub-setup: info: opening the device `/dev/sdd'
grub-setup: info: changing current directory to /dev/mapper
grub-setup: info: getting the size of /mnt2/boot/grub/boot.img
grub-setup: info: reading /mnt2/boot/grub/boot.img
grub-setup: info: getting the size of /mnt2/boot/grub/boot.img
grub-setup: info: getting the size of /mnt2/boot/grub/core.img
grub-setup: info: reading /mnt2/boot/grub/core.img
grub-setup: info: getting the size of /mnt2/boot/grub/core.img
grub-setup: info: the size of hd0 is 1953525168
grub-setup: info: setting the root device to `khyber-test1-root'
grub-setup: info: dos partition is -1, bsd partition is -1
grub-setup: info: will embed the core image at sector 0x1
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'
grub-setup: info: opening the device `/dev/sda'

> I find it very disturbing that grub touches /dev/sd[abcd], the
> drives of the host system. Even though I told it to use
> /mnt2/boot/grub as the base directory, it seems to use the
> device.map file in /boot/grub, although it seems to use the right
> boot.img and core.img files.
>
> ** Is this a separate bug? **

-- Try grub-setup more explicitly
# grub-setup -d /mnt2/boot/grub -m /mnt2/boot/grub/device.map -v '(hd0)'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: opening the device `/dev/mapper/khyber-test1--root'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: opening the device `/dev/mapper/khyber-test1--root'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: changing current directory to /dev/mapper
grub-setup: info: getting the size of /mnt2/boot/grub/boot.img
grub-setup: info: reading /mnt2/boot/grub/boot.img
grub-setup: info: getting the size of /mnt2/boot/grub/boot.img
grub-setup: info: getting the size of /mnt2/boot/grub/core.img
grub-setup: info: reading /mnt2/boot/grub/core.img
grub-setup: info: getting the size of /mnt2/boot/grub/core.img
grub-setup: error: no mapping exists for `khyber-test1-root'

> Now it appears to be using the right "drive" (judging from the
> size and the fact that there's only one), but then it does some
> /dev/mapper magic which I didn't ask it to do. In the end, it
> cannot find the mapping. I also tried to add mappings for
> "khyber-test1-root" and
> "khyber-test1--root" (i.e. without the /dev/mapper/
> prefix), but without success.

-- Try a chroot approach
# for i in proc sys dev; do mount --bind /$i /mnt2/$i; done
# chroot /mnt2 grub-setup -v '(hd0)'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: opening the device `/dev/mapper/khyber-test1--root'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: opening the device `/dev/mapper/khyber-test1--root'
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: the size of hd0 is 20971520
grub-setup: info: changing current directory to /dev/mapper
grub-setup: info: getting the size of /boot/grub/boot.img
grub-setup: info: reading /boot/grub/boot.img
grub-setup: info: getting the size of /boot/grub/boot.img
grub-setup: info: getting the size of /boot/grub/core.img
grub-setup: info: reading /boot/grub/core.img
grub-setup: info: getting the size of /boot/grub/core.img
grub-setup: error: no mapping exists for `khyber-test1-root'

> The exact same result (and also for grub-install)...



It turns out that grub2 cannot install itself onto just any block
device because it tries to be too smart. I think grub-setup (and
grub-install) need a flag with which I can tell them that I don't
want them to decompose the device I give, but just use it directly,
o.g.

  grub-install --root-directory=/mnt2 --use-device-directly /dev/mapper/khyber-test1--root

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29-1-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash


-- 
 .''`.   martin f. krafft <madduck at d.o>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20090427/d781f055/attachment-0001.pgp>


More information about the Pkg-grub-devel mailing list