Howto: Transform a qemu image to a VirtualBox image [2. Update]

Transform a qemu image to a VirtualBox image
Virtual Machines are an easy way to provide new applications or even entire operating systems without the need to install or alter anything in an existing system. However, often they are provided as a qemu image while VirtualBox is much more userfriendly.

A good example for an important qemu image is KDE’s KDE 4 daily builds virtual machine. I wanted to use it, but in contrast to qemu, VirtualBox comes along with a well designed GUI and is simply much more userfriendly (and of course also exists in a free version).

To use the qemu image in VirtualBox, first of all qemu must be installed on the computer. In Fedora this can be done by yum install qemu, for example. Also, later on a tool called “vditool” is needed. This can be downloaded at VirtualBox’ homepage: save the following link by right click to some place on your hard disk: www.virtualbox.org/download/testcase/vditool. VirtualBox should be installed already as well.

Afterwards, the image can be converted via qemu to a raw format. This raw format can be transformed to the VirtualBox compatible “vdi” type. Last but not least the image can be shrinked down a bit to only take the space it really needs:

$ qemu-img convert kde4daily-0_0_1_r734472-qcow.img kde4daily.bin

$ ./vditool DD kde4daily.vdi kde4daily.bin
vditool    Copyright (c) 2004-2005 InnoTek Systemberatung GmbH.

Converting VDI: from DD image file="kde4daily.bin" to file="kde4daily.vdi"...
Creating fixed image with size 3758096384 Bytes...
The operation completed successfully!
Writing data...
The operation completed successfully!

$ ./vditool SHRINK kde4daily.vdi
vditool    Copyright (c) 2004-2005 InnoTek Systemberatung GmbH.
Shrinking VDI image file="kde4daily.vdi"...
progress: 0%Log created: 2007-11-23T20:56:29.959543000Z
[...]
..........10%..........20%..........30%..........40%..........50%..........60%..........70%..........80%..........90%..........100%Dumping VDI image "kde4daily.vdi" mode=r/w fOpen=0 File=00000004
[...]
The operation completed successfully!

Of course the file names must be altered according to particular needs.

Afterwards, move the image to an appropriate place, create a new virtual machine instance with VirtualBox and choose the new vdi image as the hard disk of the new vm instance. Now the virtual machine can be configured and started just like any other one.

In case of the example above there was some attention still necessary to bring up the network: it wasn’t activated by default somehow, but a simple

$ sudo su
Password:
$ ifconfig eth1 up
$ dhclient eth1

fixed the problem.

Update
Naveed Hasan mentioned that vditool is obsolete and that VBoxManage can be used for it. VBoxManage is part of the VirtualBox standard installation and offers quite a lot of options – among others the possibility to convert one format to another: VBoxManage convertdd kde4daily.bin kde4daily.vdi and VBoxManage modifyvdi kde4daily.vdi compact.

2. Update
The image contains a hard-coded MAC-address for the internet connection. Simply remove the MAC address from the /etc/iftab file, and the network problem mentioned above should be gone. Thanks to Martin for the tip.

KDE 4 daily builds in a virtual machine

KDE 4 daily builds in a virtual machine
SSJ created a virtual machine containing a KDE 4 build an equipped with scripts to update the machine on a daily rhythm. Equipped with that virtual machine everyone can now easily follow the development of KDE 4 without modifying a real system.

The virtual machine project was announced today on the dot and was warmly welcomed. With the help of the virtual machine many more people will be able to test and try KDE 4 with the result that KDE will get many more bug tests and reports. Also, since the virtual machine can be updated on a daily base it is also a handy tool for normal users without a local installation of KDE to take part in the bug krush Saturdays. It is built upon Kubuntu can be downloaded via bittorrent. The image format is a bz2 packed qemu image. The login is the same as the password kde4daily.

The virtual machine is a great idea and will be of great benefit to KDE 4 and with a bit of luck also to the bug krush days. It is something I have been waiting for since the first screenshots of KDE 4 appeared, and SSJ has done a great job. Thanks for that!

Btw., since this is a virtual machine there are of course two shortcomings: speed and OpenGL. The first one will damp the experience of KDE 4 a bit since everything will be significant slower and will feel sluggier. The second part, missing OpenGL, will result in a not-compositing KWin 4.
To get rid of these limitations KDE 4 has to be installed. There is also a LiveCD which is still slower than native but at least least provides OpenGL support.