help-grub
[Top][All Lists]
Advanced

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

Installing grub to raw image


From: Jeremy Davis
Subject: Installing grub to raw image
Date: Wed, 07 Oct 2015 13:32:15 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0

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

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

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

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



reply via email to

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