Hi David,

If it was me I would copy the harddrive with dd before I do anything. Doesn't matter if its live (mounted), you can use fsck to clean this up later. You may have some problems if the disk is really busy while you do this. Be aware of weather you have taken an image of the entire drive or one of the partitions before running fsck.

You can manipulate the image of the drive with losetup (/dev/loop*), and the individual partitions with kpartx(/dev/mapper/*, kpartx -l will show). Use fsck to clean the filesystems. I would then shrink it so its more portable, so use e2fsresize or similar. Shrink it to its smallest possible size. You may find benefit in breaking each partition into a separate image, just dd the /dev/mapper/* to an appropriate image of each partition. When your done use losetup/kpartx do remove any mappings to the original image.

Create your virtual machine with a disk big enough to hold the image of the original + whatever operational space is needed. You will need some way to access the original image, so you may want to configure the image as some virtual drive or setup network access. I'm pretty sure virtual box starts out as fully virtualized, so I think its just a matter of creating the VM then installing the appropriate kernel/modules for parra virtual support.

Before you begin, have a quick read of dmesg to find out what the net drive/interface names are. Then dd the processed image/images to the newly created virtual hard disk. If you took an image of the disk as a whole, I would first setup your virtual hard disk to look like the one of the original drive, use fdisk to do this. You can find out what it should roughly like by looking at fdisk on the original. If you just copy the image of the entire drive, then you wont need to worry about fdisk step. When you've got the image copied across with dd, then you may need to amened /boot/grub or /etc/lilo.conf to relfect the virtual hard disk names. You will also need to change the mappings in /etc/fstab. For network you may need to change /etc/network/interfaces.

You may want to try one of the linux-*-virtual packages, this apparently has some parra virtualization support which may give some performance increases. I'm not sure if the pv stuff is there for virtualbox though :/ Either way, don't get your hopes up because I often find the pv stuff is broken at some level.

Hope this gives you a rough idea of how I'm doing it. I've turned heeps of production servers into stable VM's using this method. Feel free to shoot me more questions. I'm sure I missed some steps, but I'm sure you will have fun figuring out what they are :)

Best Regards,
David Balnaves

-----Original Message----- From: david
Sent: Friday, November 19, 2010 3:25 PM
To: [email protected]
Subject: [SLUG] Converting a Hard Drive to a Virtual Machine

I have an Ubuntu box running which I would like to be able to clone into
a virtualbox VM.

I don't want to shut the hardware down, or play with it too much because
it's a live server.

Is it possible to use MondoRescue or some other software to clone the
server hard drive, preferably without shutting it down, and then create
a virtual machine from the resulting image?

Thanks...

David
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to