Claes Ström's picture

I helped a friend this weekend to install the WordPress Appliance on a server with KVM.

Here is my "Recipe":


1. Download the VMDK-file and Unzip it


2. Convert the Vmware-image to QEMU Raw-format with:

qemu-img convert turnkey-wordpress-2009.10-2-hardy-x86.vmdk sda.img


3. Mount the image temporary:

If you look att Disk-image with "fdisk -ul sda.img" you see that "sda1" starts at unit 32 and that an unit is 512 bytes (32x512=16384). Mount it like this:

mount -o loop,offset=16384 sda.img /mnt


4. Create support for Serial Console:

In /mnt/etc/grub/menu.lst add the following in the top:

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=15 serial console

Change the kernel-lines in the end to look like:

kernel          /boot/vmlinuz-2.6.2..... ro quiet splash console=tty0 console=ttyS0,115200n8

Create /mnt/etc/event.d/ttyS0 with following content:

# ttyS0 - getty
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

exec /sbin/getty 115200 ttyS0


5. Set static IP:

Edit /mnt/etc/network/interfaces to look like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static


6. Setup DNS:

Edit /mnt/etc/resolvconf/resolv.conf.d/base to look like this:



7. Unmount the Image:

umount /mnt


8. Create an XML-file for KVM:

I modified an existing file and got this (wp.xml):

<domain type='qemu' id='2'>
    <type arch='x86' machine='pc'>hvm</type>
    <boot dev='hd'/>
  <clock offset='utc'/>
    <disk type='file' device='disk'>
      <source file='/srv/virt/wp/sda.img'/>
      <target dev='hda' bus='virtio'/>
    <interface type='bridge'>
      <mac address='52:54:00:aa:12:34'/>
      <source bridge='br0'/>
      <target dev='vnet2'/>
      <model type='virtio'/>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target port='0'/>

Don't forget that mac address must be unique.


9. Define it in KVM and make it autostart with help of virsh:

Start virsh and type:

define wp.xml
autostart wp

Start up your new virtual machine with virsh and play with it...

start wp
console wp


That's all folks!

Claes Ström's picture

Was everything clear or was it ununderstandable?


One thing to change if you have newer libvirt/kvm running is to have "kvm" instead of "qemu" in the first line of the xml-file with the machine definition. "kvm" gives hardware acceleration and "qemu" not!

<domain type='kvm' id='2'>


And to get swap to work and use kvm's virtual driver for disk change /etc/fstab to:

proc        /proc    proc    defaults            0 0
/dev/vda1    /    ext3    noatime,errors=remount-ro    0 1
/dev/vda2    none    swap    sw                0 0

Maybe upcoming 10.04 based turnkeys could have Serial Console included by default?


10.04 have ttyS0 defined in /etc/init/ttyS0.conf (instead of /etc/event.d/ttyS0) with content like:

# ttyS0 - getty
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

exec /sbin/getty -L 115200 ttyS0 vt102



One more tip: If you upgrade your Ubuntu/KVM server to 10.04, you need to load the kernal kvm-modules (kvm and kvm-amd or kvm-intel), ie put them in /etc/modules which earlier versions not needed.



(I spent a whole day after my upgrade to 10.04 to get everything to work again...)

Liraz Siri's picture

Great work documenting your experience with KVM. In fact, I think this would make a great addition to the community documentation. Probably under the virtualization notes page. You'll notice there's a link on the bottom to "Add child page". Don't worry about making mistakes, we can always fix that later.

Oh and sorry for the lag in response time, we're working on launching the TurnKey Hub private beta as well as coming out with betas of the Lucid based appliances. That's been keeping us unusually busy...

Claes Ström's picture

After and if Tkl based on some newer platform than 8.04 been released, then I going to try write up this doc.


Claes Ström's picture

ls -al /srv/vm/templates/images/turnkey/turnkey-zimbra-2009.10-2-hardy-x86/turnkey-zimbra-2009.10-2-hardy-x86.vmdk.img


Are you able to mount the image again after your modifications?


What platform and versions are you on?


Could you test to move your image-map "nearer" root (shorter paths) and see if it work (may some maxlength of parameter strings to kvm/qemu)


You have not changed the domain type to kvm in the xml-file, or have you?



torusJKL's picture


sudo chmod 774 /srv/vm/templates/images/turnkey/turnkey-zimbra-2009.10-2-hardy-x86/turnkey-zimbra-2009.10-2-hardy-x86.vmdk.img

Add new comment