<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>khax.net &#187; libvirt</title>
	<atom:link href="http://blog.khax.net/tag/libvirt/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.khax.net</link>
	<description>Adventures in Ubuntu systems administration</description>
	<lastBuildDate>Thu, 08 Jul 2010 02:01:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.khax.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/6ccca40b5ab19d33d91882e4d8f9a9c4?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>khax.net &#187; libvirt</title>
		<link>http://blog.khax.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.khax.net/osd.xml" title="khax.net" />
	<atom:link rel='hub' href='http://blog.khax.net/?pushpress=hub'/>
		<item>
		<title>Creating JeOS virtual machines in Ubuntu</title>
		<link>http://blog.khax.net/2009/02/24/creating-jeos-virtual-machines-in-ubuntu/</link>
		<comments>http://blog.khax.net/2009/02/24/creating-jeos-virtual-machines-in-ubuntu/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 07:36:15 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[KVM]]></category>
		<category><![CDATA[libvirt]]></category>
		<category><![CDATA[vmbuilder]]></category>
		<category><![CDATA[jeos]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[virsh]]></category>
		<category><![CDATA[virt-install]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=7</guid>
		<description><![CDATA[The two tools I use for creating new vm&#8217;s with libvirt are virt-install and vmbuilder. I use virt-install when I will be installing an OS from installable media or using an existing disk image, and vmbuilder when I need to create JeOS based vm&#8217;s. After following the guides at wiki.ubuntu.com I ended up with two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=7&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The two tools I use for creating new vm&#8217;s with libvirt are virt-install and vmbuilder. I use virt-install when I will be installing an OS from installable media or using an existing disk image, and vmbuilder when I need to create JeOS based vm&#8217;s.</p>
<p>After following the guides at wiki.ubuntu.com I ended up with two fairly long template commands:</p>
<pre>sudo virt-install --hvm -n &lt;hostname&gt; -r &lt;memory&gt; -f &lt;hdd_image&gt; -s &lt;image_size_in_gb&gt; \
-c &lt;iso&gt; --accelerate --connect=qemu:///system --vnc --noautoconsole</pre>
<pre>sudo vmbuilder kvm ubuntu --suite intrepid --flavour virtual --arch amd64 -o --libvirt qemu:///system \
--part vmbuilder.partition --user myname --name 'My Name' --pass default --addpkg puppet \
--addpkg unattended-upgrades --addpkg acpid --mirror http://apt/ubuntu --tmpfs - \
--firstboot vmbuilder.firstboot.sh --hostname &lt;hostname&gt; --mem &lt;memory&gt; --dest &lt;hdd_image_basedir&gt;</pre>
<p>The command for virt-install is pretty lean compared to the command for vmbuilder. But vmbuilder allows for most of the configuration to be stored in ~/.vmbuilder.cfg. It did take a bit of digging as not a lot about it was on the <a href="https://help.ubuntu.com/community/JeOSVMBuilder" target="_blank">ubuntu wiki</a> though.<span id="more-7"></span></p>
<p>If you are looking for extra help in vmbuilder have a look at:</p>
<pre>vmbuilder kvm ubuntu --help</pre>
<p>And after setting up the config files below, to create new machines I just use for example:</p>
<pre>sudo vmbuilder kvm ubuntu --hostname cacti --mem 256 --dest /srv/libvirt/cacti/</pre>
<p>So here is the config I use as an example for anybody who plans on using vmbuilder a lot.</p>
<h4>~/.vmbuilder.cfg</h4>
<pre>[DEFAULT]
arch = amd64
part = vmbuilder.partition
user = myname
name = My Name
pass = default
tmpfs = -
firstboot = vmbuilder.firstboot.sh
firstlogin = vmbuilder.firstlogin.sh

[ubuntu]
mirror = http://apt/ubuntu
suite = intrepid
flavour = virtual
addpkg = puppet, unattended-upgrades, acpid
part = vmbuilder.partition
#ssh_user_key = .ssh/authorized_keys

[kvm]
libvirt = qemu:///system</pre>
<p>http://apt/ubuntu is my local approx machine for caching packages. The ssh_user_key is commented out at the moment as it creates the file correctly in the user account, but sets the owner to root.</p>
<h4>vmbuilder.partition</h4>
<pre>root 8000
swap 4000</pre>
<h4>vmbuilder.firstboot.sh</h4>
<pre># This script will run the first time the virtual machine boots
# It is ran as root.

locale-gen en_AU.UTF-8

apt-get update
apt-get install -qqy --force-yes openssh-server</pre>
<p>The firstboot script just ensures that if I create an image and duplicate it a few times that each machine will have a unique ssh host key. But the image must be duplicated before the first boot.</p>
<h4>vmbuilder.firstlogin.sh</h4>
<p># This script will run the first time the virtual machine boots<br />
# It is ran as root.</p>
<p># Prompt for a password change<br />
passwd</p>
<p>Because I did not want to put my password in the configuration files as plain text, I only put default as the password and when I login for the first time I am prompted to change it. This will hopefully be fixed when I get the ssh_user_key working though.</p>
<h4>VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl</h4>
<pre>&lt;domain type='kvm'&gt;
  &lt;name&gt;$hostname&lt;/name&gt;
  &lt;memory&gt;#echo $mem * 1024 #&lt;/memory&gt;
  &lt;vcpu&gt;1&lt;/vcpu&gt;
  &lt;os&gt;
    &lt;type&gt;hvm&lt;/type&gt;
    &lt;boot dev='hd'/&gt;
  &lt;/os&gt;
  &lt;features&gt;
    &lt;acpi/&gt;
  &lt;/features&gt;
  &lt;clock offset='utc'/&gt;
  &lt;on_poweroff&gt;destroy&lt;/on_poweroff&gt;
  &lt;on_reboot&gt;restart&lt;/on_reboot&gt;
  &lt;on_crash&gt;destroy&lt;/on_crash&gt;
  &lt;devices&gt;
    &lt;emulator&gt;/usr/bin/kvm&lt;/emulator&gt;
    &lt;interface type='bridge'&gt;
      &lt;source bridge='br0'/&gt;
      &lt;model type='virtio'/&gt;
    &lt;/interface&gt;
    &lt;input type='mouse' bus='ps2'/&gt;
    &lt;graphics type='vnc' port='-1' listen='127.0.0.1'/&gt;
#for $disk in $disks
    &lt;disk type='file' device='disk'&gt;
      &lt;source file='$disk.filename' /&gt;
      &lt;target dev='hd$disk.devletters()' /&gt;
    &lt;/disk&gt;
#end for
  &lt;/devices&gt;
&lt;/domain&gt;</pre>
<p>And the only difference with this template and the default one is this template file sets up bridge networking with virtio by default.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=7&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/02/24/creating-jeos-virtual-machines-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows XP p2v conversion with KVM</title>
		<link>http://blog.khax.net/2009/02/08/windows-xp-p2v-conversion-with-kvm/</link>
		<comments>http://blog.khax.net/2009/02/08/windows-xp-p2v-conversion-with-kvm/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 01:12:43 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[KVM]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[clonezilla]]></category>
		<category><![CDATA[libvirt]]></category>
		<category><![CDATA[qemu]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[windows xp]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=9</guid>
		<description><![CDATA[After all of the Windows and Linux virtual machines I have setup I decided to try a Windows p2v (Physical to Virtual) conversion. After bracing for the worst it ended up being fairly straight forward. Steps as follows: Create a disk image of sufficient size Copy the Windows HDD to the disk image Boot the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=9&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After all of the Windows and Linux virtual machines I have setup I decided to try a Windows p2v (Physical to Virtual) conversion. After bracing for the worst it ended up being fairly straight forward. Steps as follows:</p>
<ol>
<li>Create a disk image of sufficient size</li>
<li>Copy the Windows HDD to the disk image</li>
<li>Boot the image with KVM</li>
</ol>
<p>Yip. Only three steps. Beware that Windows p2v images have all run quite slow for me compared to Windows images that were originally installed in KVM. This I guess is just because of the cruft buildup in Windows and all the driver changes that Windows seems to balk at so much.</p>
<p>Although these instructions are written using Window XP as the guest image, it will work equally (extremely) well for Linux too. The only exception with linux being that you can substitute the clonezilla step for a straight tar copy of the images. Using clonezilla for Windows and Linux though reduces the number of different steps to remember.<span id="more-9"></span></p>
<h3>Create a disk image of sufficient size</h3>
<p>I chose to use qcow2 for spaces sake as I am only testing this on my laptop. Feel free to use any type of disk image that KVM supports.</p>
<p>qemu-img create -f qcow2 windowsxp.qcow2 80G</p>
<h3>Copy the Windows HDD to the disk image</h3>
<p>For this step I pulled the HDD from the machine to convert and connected it via a usb sata converter. The HDD was then accessible at /dev/sdc. However you connect the HDD to your computer, be it internally or externally, you will need to be able to access it as a block device. So just substitute my references to /dev/sdc with the location of your source HDD.</p>
<p>For copying from p2v I chose to use <a href="http://www.clonezilla.org/">clonezilla</a> again after how handy it has been for resizing NTFS images for me (<a href="http://bryan-murdock.blogspot.com/2007/12/resize-qemukvm-windows-disk-image.html">ref</a>). Download a clonezilla livecd iso from <a href="http://www.clonezilla.org/download/sourceforge/stable/iso-zip-files.php">here</a>.</p>
<pre>kvm -m 256 -boot d -cdrom clonezilla-live-1.2.1-39.iso -hda /dev/sdc -hdb widowsxp.qcow2</pre>
<p>After booting I selected a disk to disk copy and just accepted all of the default options. I will work both with NTFS and FAT32 partitions. The main thing to be aware of when using clonezilla is that the PHYSICAL drive gets selected as the source. It&#8217;s description in clonezilla will be similar to the writing on the HDD label.</p>
<p>If you have more than one HDD for this machine then just repeat the above steps for each disk.</p>
<p>If there source machine is using RAID then you first need to burn the clonezilla iso to cd or create a clonezilla live usb stick. Boot the source machine with clonezilla and copy the source HDD to a spare HDD first, then connect the spare HDD to your machine and copy that. Clonezilla does have options for network copy that may save a lot of extra work in this step, but I have not had time to explore them yet.</p>
<h3>Boot the image with KVM</h3>
<p>On first boot Windows will detect all the hardware changes and install drivers for them. Most emulated hardware in KVM already has drivers in Windows and I did not get prompted for any drivers etc.</p>
<pre>kvm -m 512 -usb -usbdevice tablet -hda windowsxp.qcow2</pre>
<p>Upon Windows detecting such hardware changes you will also need to reactivate Windows again too. If you are using libvirt then you can also create a new xml definition and manage the image that way.</p>
<p>If you had any static ip addresses defined in Windows these will need to be setup again too as Windows will have detected new network cards. For Ubuntu it is not so much that the network cards have changed but that the MAC address has changed and the new card is likely assigned to eth1 instead of eth0. If you still want the network card referred to as eth0 the edit /etc/udev/rules.d/70-persistent-net.rules and remove the two line referencing your old network card then reboot and your cards will be named correctly. Or just change /etc/network/interfaces to from eth0 to eth1 as appropriate.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=9&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/02/08/windows-xp-p2v-conversion-with-kvm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
	</channel>
</rss>