<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Fun with ones and zeros - xen</title>
<subtitle>Barry&#039;s notes on computer software and hardware</subtitle>
<link href="/blog/tags/xen"></link>
<updated>2026-05-20T03:45:42-07:00</updated>
<id>urn:uuid:f315631b-ab5e-54c7-5a70-5c5d40300ccc</id>
<entry>
<title>Playing with KVM and LVM on Linux</title>
<link href="/blog/entries/playing-kvm-and-lvm-linux"></link>
<id>urn:uuid:3688ef99-a82d-ea5d-c912-bf76285790ac</id>
<updated>2008-12-04T09:25:38-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">
&lt;p&gt;I&#039;m still experimenting with Ubuntu 8.04 Server (Hardy Heron), and have switched from Xen to KVM (Kernel-based Virtual Machine).  Xen worked well on a little test machine I had, but when I tried it on a brand-new Supermicro server, it turned out to have a &lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/xen-3.2/+bug/236268&quot;&gt;problem with the Intel NIC&lt;/a&gt;.  Since it seems Ubuntu is recommending KVM over Xen, and the server supports hardware virtualization, I figured I&#039;d give it a try.
&lt;/p&gt;
&lt;p&gt;One big difference is that KVM does &lt;em&gt;full&lt;/em&gt; emulation, which means any disk space you give it from LVM (Logical Volume Manager), will be a full virtual disk, with a partition table.  It&#039;s a little more complicated to access filesystems within the virtual disk that it was with Xen, I wanted to jot some notes down here mostly for myself on how to do that.
&lt;/p&gt;
&lt;p&gt;If I&#039;ve created a logical volume named &lt;code&gt;/dev/myvg/test_vm&lt;/code&gt; and installed another linux on it with a single ext3 filesystem (/dev/sda1 from the point of view of the VM) and some swap space (/dev/sda5), it can be accessed when the VM isn&#039;t running with the help of the &lt;code&gt;kpartx&lt;/code&gt; utility...
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;kpartx -av /dev/myvg/test_vm
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;would read the partition table on the virtual disk and create:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/dev/mapper/myvg-test_vm1 
/dev/mapper/myvg-test_vm2 
/dev/mapper/myvg-test_vm5
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then you can
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mount /dev/mapper/myvg-test_vm1 /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to mess with the VMs &lt;code&gt;/dev/sda1&lt;/code&gt;.  To clean things up when finished, run:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;umount /mnt
kpartx -d /dev/myvg/test_vm
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Snapshots&lt;/h3&gt;
&lt;p&gt;If you want to look at the contents of a running VM&#039;s disks (perhaps for backing it up) you can use LVM snapshots. For example:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;lvcreate --snapshot --size 1G --name test_snap /dev/myvg/test_vm
kpartx -av /dev/myvg/test_snap
mount /dev/mapper/myvg-test_snap1 /mnt
   .
   (play with VM&#039;s /dev/sda1 in /mnt)
   .
umount /mnt
kpartx -dv /dev/myvg/test_snap
lvremove /dev/myvg/test_snap
&lt;/code&gt;&lt;/pre&gt;

</content>
</entry>
<entry>
<title>Xen and UFW on Ubuntu</title>
<link href="/blog/entries/xen-and-ufw-ubuntu"></link>
<id>urn:uuid:788b4189-21a0-395c-27cb-0f1edccc4a0a</id>
<updated>2008-10-23T08:43:49-07:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">
&lt;p&gt;I&#039;ve been experimenting with setting up Ubuntu Server 8.04 (Hardy Heron) to run Xen, and had a minor problem with UFW (Uncomplicated Firewall) running in the dom0 blocking network access to a domU running in bridged mode.  It seems the fix is just to edit &lt;code&gt;/etc/defaults/ufw&lt;/code&gt; and make this change to enable forwarding:
&lt;/p&gt;
&lt;div class=&quot;source&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gd&quot;&gt;--- a/default/ufw       Thu Oct 23 10:00:33 2008 -0500&lt;/span&gt;
&lt;span class=&quot;gi&quot;&gt;+++ b/default/ufw       Thu Oct 23 10:34:36 2008 -0500&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;@@ -16,7 +16,7 @@ DEFAULT_OUTPUT_POLICY=&amp;quot;ACCEPT&amp;quot;&lt;/span&gt;

 # set the default forward policy to ACCEPT or DROP.  Please note that if you
 # change this you will most likely want to adjust your rules
&lt;span class=&quot;gd&quot;&gt;-DEFAULT_FORWARD_POLICY=&amp;quot;DROP&amp;quot;&lt;/span&gt;
&lt;span class=&quot;gi&quot;&gt;+DEFAULT_FORWARD_POLICY=&amp;quot;ACCEPT&amp;quot;&lt;/span&gt;

 #
 # IPT backend
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and then run &lt;code&gt;ufw disable; ufw enable&lt;/code&gt;.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I &lt;em&gt;believe&lt;/em&gt; dom0 is now protected, and it&#039;ll be up the the domU to protect itself.  I can&#039;t say I&#039;m entirely comfortable with Linux IPTables, sure wish PF was available as an alternative.
&lt;/p&gt;
</content>
</entry>
</feed>