<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>olivetalks &#187; HVM</title>
	<atom:link href="http://www.olivetalks.com/tag/hvm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.olivetalks.com</link>
	<description>The Olive has arrived and it has things to say…</description>
	<lastBuildDate>Tue, 16 Nov 2010 19:25:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Xen p2v conversion in seven simple steps</title>
		<link>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/</link>
		<comments>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 11:18:20 +0000</pubDate>
		<dc:creator>ZoltarStark</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[fully virtualized]]></category>
		<category><![CDATA[HVM]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[SCSI]]></category>
		<category><![CDATA[xen]]></category>
		<category><![CDATA[Xen guest]]></category>

		<guid isPermaLink="false">http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/</guid>
		<description><![CDATA[Easily convert a physical Linux machine to a HVM guest running under Xen. Follow seven simple steps.]]></description>
			<content:encoded><![CDATA[<p>Xen is one of the currently available virtualization technologies. The commercially supported version is now owned by Cytrix while the Open Source community edition is available at<a href="http://xen.org/"> xen.org</a>. In this article I&#8217;ll be referring to the Open Source edition of Xen, version 3.0.3 which is available by default on CentOS 5.1.</p>
<p>I&#8217;ve recently performed two conversions of physical hosts to Xen guests running on CentOS 5.1 host. The physical hosts were running RHEL 3.7 and CentOS 4.6. It is important to know that after the conversion you end up with a fully virtualized guest &#8211; HVM. This has its effect on the performance, especially when it comes to I/O. It is a general limitation of fully virtualized Xen guests and not of this particular P2V method. I don&#8217;t recommend using it for virtualizing for example a file server. In such a case your only real choice is to create a new paravirtualized guest and migrate the services. This article won&#8217;t be describing that approach.</p>
<p>These instructions are based on the <a href="http://www.linuxjournal.com/article/9942">article</a> by Kyle Rankin. I&#8217;ve adapted it for Xen and added comments on those things which did cause me trouble. The instructions have been used to virtualize RHEL and CentOS servers to run as Xen guests on CentOS 5.1 but you should be able to use most of them for other distributions.</p>
<p><strong>First step</strong> in the conversion is to create LVM volume(s) in the Xen host to be used by the guest. To figure out how much space you need,   have a look at the physical server you want to virtualize. Each LVM volume will be visible in the guest as a separate hard disk. Note that HVM guests support only up to four disks. You will partition the disks from inside the guest in step two.</p>
<p><strong>Second step</strong> is to create a new HVM guest and boot it from a bootable rescue CD/DVD. You should use a rescue CD which matches the architecture of the physical host being virtualized. In step four you need to run <code>chroot</code> command on the guest and it won&#8217;t work if you try for example a 32 bit rescue CD on a 64 bit system. After you have already booted the guest from a rescue CD you need to create partitions to match the physical host. The easiest thing is to match exactly the number and sizes of partitions on the physical system. You can also put several file systems which were on separate partitions on the physical server on a single partition on the guest as long as you prepare enough space.</p>
<p><strong>Third step</strong> is to copy files from the physical server to the guest. This can take some time, so depending on whether you want to minimize the downtime you can do it either in one step or in two. Both methods use <code>rsync</code> command.  The second method is described by Kyle in his <a href="http://www.linuxjournal.com/article/9942">article</a>. The first method is basically the same but you only do the final synchronization. If you use a single transfer method you don&#8217;t need to use the <code>--delete</code> parameter for the final (and in this case the only) synchronization. The single transfer method is faster but it might not be available for you if you need to minimize the downtime.</p>
<p><strong>Fourth step</strong> is to adjust the boot settings in the guest. Without that the guest won&#8217;t boot. To do that make sure all the guest file systems are mounted and <code>chroot</code> into the guest root file system. From there you need to adjust the boot loader configuration. I use GRUB on my systems. For instructions on adjusting LILO you&#8217;ll have to look elsewhere.</p>
<p>First you need to change the file <code>/boot/grub/device.map</code>. If you see <code>/dev/sda</code> there you need to replace it with <code>/dev/hda</code>. This should represent your boot drive. Also verify that the guest boot partition is in <code>/etc/mtab</code>. After that you execute <code>grub-install /dev/hda</code>.</p>
<p>Another file which needs modifications is <code>/etc/grub.conf</code>. Pay attention to the lines starting with <code>boot=</code> and <code>splashimage=</code> as they probably need adjusting. The boot parameters need to be updated as appropriate. The important entries are <code>root (hd0,0)</code> and <code>root=</code> kernel parameter. Note that the first one selects the boot partition while the second selects the partition for the root file system. So for example if the boot partition is in <code>/dev/hda3</code> and root partition is <code>/dev/hda1</code> these entries should look <code>root (hd0,2)</code> (here the partitions are counted starting from zero) and <code>root=/dev/hda1</code> (here they are counted from one).</p>
<p><strong>Fifth step</strong> is to generate a new initrd file for the guest. First copy the existing initrd file somewhere in case you need it later. Then adjust the <code>/etc/modules.conf</code> or <code>/etc/modprobe.conf file</code> (only one will be present depending on the distribution and OS version). Remove all entries starting with <code>alias scsi_hostadapter</code>. After that you can run <code>mkinitrd</code> command. I recommend you use <code>-v</code> parameter for <code>mkinitrd</code>. This will list all the modules which will be included in the initrd. You will probably need at least libata and ata_piix &#8211; even if the physical server uses SCSI disks the HVM guest will use IDE. This depends on the OS of the physical machine you&#8217;re virtualizing because it was only important when I was converting the RHEL 3.7 server but not with CentOS 4.6. If they&#8217;re missing you can add them using <code>--with=</code> parameter. Another advice in case you need to verify the content of initrd file (probably because the guest doesn&#8217;t boot): take into account that older versions of <code>mkinitrd</code> produce just a gzipped ext2 filesystem while the newer ones create a gzipped cpio archive.</p>
<p><strong>Sixth step</strong> is to adjust the network settings and mount points for the guest. The configuration files you need to edit to change network settings are in <code>/etc/sysconfig/network-scripts</code>. Most likely you will have at least <code>ifcfg-eth0</code>. RHEL and CentOS usually specify the MAC address of the network adapter there so you need to change it to match with the MAC address of your guest. Otherwise when the guest boots the interface might not get activated. If you want to change the IP address of the guest you can also do it although I&#8217;d recommend to leave it for later when you already know the guest works. For the initial boot it should be easier if the guest runs with the same IP address as was used before by the physical server.</p>
<p>You also need to edit file <code>/etc/fstab</code> to match with the partition scheme defined for the guest.</p>
<p><strong>Seventh step</strong> is to boot the HVM guest which will be now able to replace the physical server. In order to avoid conflicts you should either power down the physical server, disconnect it from the network or change its IP address(es). After that you can reboot the Xen guest. If you followed the instructions and if the initrd file contains all required modules the system should boot and start all the configured services. If you&#8217;re using <code>kudzu</code> it will ask you a few questions about removed/added hardware. Kyle suggests to select &#8220;Keep Configuration&#8221; for any removed SCSI or network hardware, and select &#8220;Ignore&#8221; for any added SCSI or network hardware. If you are prompted about any removed video, sound, USB and similar hardware you can safely select &#8220;Remove Configuration&#8221;. When booting finishes verify that all required service are running and that you have network connectivity from within the guest.</p>
<p>That&#8217;s it. You should have now a fully virtualized guest running on the Xen host which has the same configuration as the physical server it replaces. It would be a good idea to perform this process first on a test physical server so you have more time to figure out solutions to any problems you may encounter.</p>
<hr align="left" width="20%" /> <a href="/category/computers/feed" title="rss feed to post"><img src="/wp-content/uploads/2008/01/feed-icon-14x14.png" alt="rss feed to post" /></a> Subscribe to the Computers posts of olivetalks, if you found this article interesting, thank you!</p>
<h3>Related post(s)</h3><ul class="related_post"><li><a href="http://www.olivetalks.com/2008/04/14/xen-centos-pe2950/" title="Xen and CentOS 5.1 on PowerEdge 2950">Xen and CentOS 5.1 on PowerEdge 2950 (2)</a></li><li><a href="http://www.olivetalks.com/2008/02/03/usb-forwarding-on-xen-it-just-does-not-work/" title="USB forwarding on Xen &#8211; it just does not work">USB forwarding on Xen &#8211; it just does not work (6)</a></li><li><a href="http://www.olivetalks.com/2008/01/24/usb-forwarding-on-xen/" title="USB forwarding on Xen">USB forwarding on Xen (1)</a></li><li><a href="http://www.olivetalks.com/2009/02/15/find-changes-with-rpm-verify/" title="What files did I change?">What files did I change? (2)</a></li><li><a href="http://www.olivetalks.com/2009/02/21/ups-on-centos-with-selinux-part-2/" title="Setting up UPS on CentOS 5.2 with SELinux, part 2">Setting up UPS on CentOS 5.2 with SELinux, part 2 (1)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.olivetalks.com/2008/02/16/xen-p2v-conversion-in-seven-simple-steps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

