[fedora-virt] P2V and grub bootloader

Dennis J. dennisml at conversis.de
Thu Apr 30 22:16:29 UTC 2009

On 04/30/2009 11:39 PM, Richard W.M. Jones wrote:
> On Thu, Apr 30, 2009 at 11:28:51PM +0200, Dennis J. wrote:
>> Hi,
>> I'm currently experimenting with converting a physical system to a
>> virtual one. Using losetup, kpartx, etc. i was able to transfer the
>> system to a volume group in an image file.
> Why not just copy across the whole block device?  This is essentially
> what virt-p2v does (http://et.redhat.com/~rjones/virt-p2v/), although
> virt-p2v is doing nothing more than automating what you could do by
> hand.
> Anyway, if you copy the whole block device (eg /dev/sda) then
> presumably grub will be copied across along with it.

virt-p2v's achilles heel for me is that it can only copy on the block 
device level. /dev/sda is 50gb in size, the root logical volume only 10gb 
and copying the files over by piping a tar into ssh allowed me to shrink it 
to 5gb in the process. also I plan to move machines that use regular 
partitioning into VMs that use LVM volumes. Also copying the 3gb of files 
is obviously faster then copying 50gb of mostly empty space.

>> How can I install grub from outside the VM?
> I haven't tried it, but it's possibly something you can do from
> libguestfs, or if not, it's something that we could add to libguestfs.

That would be great. What I'm a little confused about is the different 
perspectives of the device-space you get when simply chroot-ing into the 
VMs root filesystem and actually booting the VM. In the VM booting case 
/dev/sda is /dev/sda so a "grub-install /dev/sda" does the trick but in the 
chrooting case /dev/sda is still the physical /dev/sda (if I'm not making a 
mistake in my thinking here). That's why I thought I could "grub-install 
/dev/loop0" to treat the image file as the virtual /dev/sda.
Unfortunately that seems to confuse grub. I think I'll have to dive into 
the grub-install source to see why exactly it is complaining and how to get 
around that.


More information about the Fedora-virt mailing list