grub-devel
[Top][All Lists]
Advanced

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

Re: Mounting a virtual hard-disk and booting from it


From: Lennart Sorensen
Subject: Re: Mounting a virtual hard-disk and booting from it
Date: Fri, 24 Jun 2011 11:46:39 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Jun 21, 2011 at 03:02:14PM -0400, Swapnesh Chaubal wrote:
> I use a script from VMWare to read a virtual hard-disk and then mount it to
> a drive in Linux. How can I boot from this mounted drive using grub (I need
> to mount the drive before booting to any OS). I could have all the mounting
> stuff written in a python/bash script. However, is there a way to run that
> script from GRUB or a GRUB module?

If you expect to do it from an unmodified virtual harddisk, then you
can't.  The software in it almost certainly will expect a real disk
connected to some controller, which the virtual machine software provides.

So you have to at least modify the image to work with a virtual drive
directly.  This means that it must have an initrd that can mount the
real system's drive, find the virtual drive, loop mount that and make
it root and continue booting.

If you have such an initrd and kernel in the virtual drive, then grub
(on the main drive of course, not inside the virtual drive since the host
machine can't read that to boot) can loopback access the image and read
the kernel and initrd and boot those, after which it is entirely up to
the kernel and initrd to actually mount the virtual drive and use it.

The image most likely must be a raw disk image (not .vdi, or .vmk or
any of the other special virtual drive types that are not a stright
collection of disk blocks in a file).

Remember that once grub jumps to the kernel, nothing grub did exists
anymore, so there is no concept of mounting a drive in grub and even if
it could it wouldn't be mounted anymore as soon as you jump to the kernel.
The kernel/initrd must do the mounting.

-- 
Len Sorensen



reply via email to

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