Tip

Open source Xen provides cost-effective P2V conversions

The benefits of virtualization – including reducing hardware and power costs, minimizing data center footprint 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

    Requires Free Membership to View

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 the dd 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.

***figure1

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 expert

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.


This was first published in September 2009

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.