The benefits of virtualization – including reducing hardware and power costs, minimizing data center footprint...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
and greater data center flexibility -- are well documented. Nevertheless, the startup costs for propriety virtualization software can be high. But these costs can be mitigated by performing physical-to-virtual (P2V) conversions with open source Xen.
The basic principles of P2V conversions are easy to understand. First, you need to turn the contents of your physical machine into an image file. Once you do so, you need to be able to boot from that image file. To accomplish this, make sure that you use the correct kernel. If this sounds daunting, this article will walk you through the basics.
From physical machine to image file
First, write your physical server's contents to an image file. I prefer the one-to-one approach: one image file for each disk. If, for example, the server you want to convert has four disks, you need to repeat this procedure four times.
Rebooting the server from a Linux live system is the easiest way to clone the contents of your physical disk to an image file. You can use your distribution's installation disk or use another live system, like Knoppix. After booting your server from the live disk, find the name of the disk that you want to clone. In most cases, fdisk -l provides that information. And typically, a Linux hard disk uses a device file, such as /dev/sda.
After determining the name of your physical disk, you need to create the storage device where you want to keep the image file. Attaching an external hard drive is an easy way of doing this. Once attached, mount it somewhere in the current file system in order to write the image file to this location. Let's assume it's mounted on the /mnt directory.
Now that the preparations are complete, it's time to clone the disks. To do so, use thedd command. Then, use the following command to write the entire /dev/sda contents to a file with the name sda.img in the /mnt directory:
dd if=/dev/sda of=/mnt/sda.img bs=4096
This step can be time-consuming. It's not uncommon for a 300 GB disk, for example, to take several hours. Do something else and return to the task at the end of the day.
Including the disk image file into your Xen configuration
After creating the image file, you must include it in your Xen configuration. Using the import wizard in the virt-manager application is the easiest way. In the Virtual Machine Manager main interface, click New to create a virtual machine. Next, click Forward, and from the Create a Virtual Machine window, select I have a disk or disk image with an installed operating system.
After selecting the operating system that's on the physical server, Virtual Machine Manager will show the summary screen. In this screen, find the disk file that you previously cloned. Then select the appropriate kernel. This last step is crucial: By default, a paravirtualization kernel is selected on some operating systems . On a machine that you have just cloned with P2V, there will be no paravirtual kernel installed by default, so make sure to select Full Virtualization as the virtualization type and you'll be able to start the converted virtual machine in Xen.
About the author:
Sander van Vugt is an independent trainer and consultant based in the Netherlands. Van Vugt is an expert in Linux high availability, virtualization and performance and has completed several projects that implement all three. He is also the writer of various Linux-related books, such as Beginning the Linux Command Line, Beginning Ubuntu Server Administration and Pro Ubuntu Server Administration.
Dig Deeper on P2V, V2V and V2P migration