help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Installing grub to raw image


From: Andrei Borzenkov
Subject: Re: Installing grub to raw image
Date: Wed, 7 Oct 2015 22:07:26 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

07.10.2015 05:32, Jeremy Davis пишет:
Hi,

I am trying to install grub to a raw image (i.e. a flat file that will
be used to house a VM). Host & guest image both Debian Jessie

I have partitioned the file:
part 1 : ext2 (for boot)
part 2 : LVM (for root & swap)

I have the raw mounted to /dev/loop0 with kpartx so these partitions map to:

part 1 : /dev/mapper/loop0p1
part 2 : /dev/mapper/loop0p2


I can reproduce something similar using grub2 in openSUSE Tumbleweed (2.02~beta2 with selected patches). The problem is that grub fails to detect that /dev/mapper/loop0p1 is partition of /dev/loop0 and so it does not include partition driver. The UUID in my case was correct (that of the first partition), but grub simply could not access it.

Current upstream seems to work for me in this configuration. You may want to test if it works for you.

The LVM setup (vg labelled "lv")on part 2 provides:
/dev/mapper/lv-root
/dev/mapper/lv-swap_1

I then have it mounted like this:

/dev/mapper/lv-root -> /mnt
/dev/mapper/loop0p1 -> /mnt/boot

I then install grub like this:

devicemap=/mnt/boot/grub/device.map
chroot /mnt grub-mkdevicemap
chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
grub-install --force --grub-mkdevicemap=$devicemap --root-directory=/mnt
/dev/loop0


--grub-mkdevicemap is a) no-op, it is accepted for legacy reasons only and b) you are using it incorrectly anyway, it pointed to a program to rebuild device.map, not to device.map itself.

Which appears to install as it should:

# chroot /mnt grub-mkdevicemap
# chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.16.0-4-amd64
Found initrd image: /boot/initrd.img-3.16.0-4-amd64
done
# grub-install --force --grub-mkdevicemap=$devicemap
--root-directory=/mnt /dev/loop0
Installing for i386-pc platform.
Installation finished. No error reported.

(note that both systems are 64 bit so maybe this is the issue? But i
doubt it as the host has the same info...)

So this appears to all complete fine...

But when I boot the raw image I get an error about a device not found (a
UUID that I have no idea where it comes from. It does not appear to
match any of the UUIDs that I see in the grub.cfg so I have no idea
where this is coming from!?)

I can fix grub easy enough from the vm:
-boot with live iso
-mount /dev/mapper/lv-root as /mnt & /dev/sda1 as /mnt/boot
# grub-install --root-directory=/mnt /dev/sda

Once grub is repaired than all works as it should, however I want it to
just work from the start...

 From looking around inside the (unbootable) raw it just looks like grub
wasn't installed properly...

# ls -l /mnt/grub
total 2363
-rw-r--r-- 1 root root      50 Oct  7 01:47 device.map
-r--r--r-- 1 root root    5657 Oct  7 01:47 grub.cfg
-rw-r--r-- 1 root root 2400500 Oct  6 10:18 unicode.pf2


Yes, it looks like grub installed somewhere else. You may want to run grub-install --debug ... to see what it did.

Nothing like (working) /boot/grub on the host:

# ls -l /boot/grub
total 2380
drwxr-xr-x 2 root root    4096 Aug 31 01:01 fonts
-r--r--r-- 1 root root    7882 Oct  7 00:52 grub.cfg
-rw-r--r-- 1 root root    1024 Aug 31 01:01 grubenv
drwxr-xr-x 2 root root   12288 Oct  7 00:56 i386-pc
drwxr-xr-x 2 root root    4096 Aug 31 01:01 locale
-rw-r--r-- 1 root root 2400500 Aug 13 13:08 unicode.pf2

FWIW the fixed /boot/grub dir looks the same as the host...

Any help/guidance/insight/etc warmly welcomed!

Regards,
Jeremy Davis

_______________________________________________
Help-grub mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-grub





reply via email to

[Prev in Thread] Current Thread [Next in Thread]