How to do grub-install on a (non loading) virtual guest

How to do grub-install on a (non loading) virtual guest

Ehud Karni ehud at unix.mvs.co.il
Mon Sep 21 18:15:24 IDT 2009


On Mon, 21 Sep 2009 07:05:48 +1000, Amos Shapira <amos.shapira at gmail.com> wrote:
>
> I'm not sure why you have to create the device files, though - unless
> the vm filesystem is too screwed up for chroot (which it doesn't
> appear in your case), you shlould be able to (after your kpartx
> command):
> 1. Mount the vm's root partition (e.g. On /mnt/root).
> 2. "mount -bind /$x /mnt/root/$x" for $x in "dev", "sys" and "proc"
> 3. Chroot /mnt/root
> 4. Do your stuff
> 5. Reverese the above.
>
> That'a how, for instance, I used to install Ubuntu desktop version
> with LVM2 (which didn't support setting up LVM2 in its installation
> disk).

Your above recipe differ from mine just by using the host devices as
is (i.e. not creating different devices on the non-running guest /dev).

Did you try it ?  I don't think this will work, because what I'm really
doing is mapping the HOST /dev/loop7 into the GUEST /dev/hda, and (HOST)
/dev/mapper/loop7p1 into (GUEST) /dev/hda1.

I don't have /dev/hda in the host /dev but I need it the guest /dev.

You can use mount -bind of /dev if you also create the right sym-links
e.g.  ln -s /dev/loop7 /dev/hda
and   ln -s /dev/mapper/loop7p1 /dev/hda1
but then you may have problems if the host have a real /dev/hda.

You may skip the sym-linking and change the grub device map
(/boot/grub/device.map) to have the line:
(hd0)  /dev/loop7
but then you may have other problems (grub-install want find /dev/loop71,
you would not be able to run grub-install from within the guest itself
without restoring the device.map .

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7976-561  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry



More information about the Linux-il mailing list