CSS Corp Open Source Services

Bundling FreeBSD Image for OpenStack

with 2 comments

This article explains how to create a  FreeBSD 8.2 image on KVM for uploading it to the image store on OpenStack Diablo. The procedure also covers installation of Virtio drivers, as it is essential for an instance running on OpenStack. I have used KVM running on Ubuntu 11.10 64-bit server for creation of the image.

The first step would be to create a qcow2 image. This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need

kvm-img create -f qcow2 freebsd.img 5G

Start the Virtual Machine and boot from the CD.

kvm -m 256 -cdrom FreeBSD-8.2-RELEASE-i386-disc1.iso -drive file=freebsd.img,if=scsi,index=0 -boot d -net nic -net user -nographic -vnc :1

Connect to the Virtual Machine through VNC (use display number :1) where is the IP address of the host machine.

vncviewer :1

During the post-installation configuration, enable SSH server. Also enable dhcp for the interface re0.

Shutdown the Virtual Machine and  power it on to boot from the Hard Drive using the following command.

kvm -m 256 -drive file=freebsd.img,if=scsi,index=0,boot=on -boot c -net nic -net user -nographic -vnc :1

We need to install the Virtio driver for the image to work with OpenStack. For installing the Virtio driver perform the following steps.

Download the compressed snapshot of the ports collection.

portsnap fetch

Extract the snapshot into /usr/ports.

portsnap extract

Download the kernel source using the following steps.


Select Configure -> Distributions which will give you many components that it can install. Select “src”. It will in turn show you some sub components. Select “sys”. Install the components. This will download the kernel source which is needed for the compiling the drivers.
In order to install the Virtio driver, we need to install Subversion and download the source for the driver.

cd /usr/ports/devel/subversion
make install
make clean
cd /usr/src/sys/dev
svn co http://svn.freebsd.org/base/projects/virtio/sys/dev/virtio
cd /usr/src/sys/modules
svn co http://svn.freebsd.org/base/projects/virtio/sys/modules/virtio
cd /usr/src/sys/modules/virtio
make install

Add the following lines to /boot/loader.conf to load Virtio drivers on boot.


Now the installation and configuration of the virtio driver is over. Make any other changes needed for the image.

Edit the file /etc/fstab to boot from the original drive with Virtio interface.

cp /etc/fstab /etc/fstab.bak
cat /etc/fstab.bak | perl -pe "s/da/vtbd/g;" > /etc/fstab

SSH access for root and password authentication is disabled by default.  Edit /etc/ssh/sshd_config to enable these.

PermitRootLogin yes
PasswordAuthentication yes

TODO: key injection

Shutdown the Virtual Machine and upload the image to OpenStack using the following command.

cloud-publish-image amd64 freebsd.img freebsdbucket

The following output shows that the image has been successfully uploaded.

ami-00000001 freebsdbucket/freebsd.img.manifest.xml

Verify whether the instance boots from the uploaded image.

euca-run-instances ami-00000001 -t m1.tiny


2 Responses

Subscribe to comments with RSS.

  1. Hi I’ve tried your steps and it worked!
    The only thing that I couldnt have it work is on booting it on the harddrive…
    I’m using Ubuntu Server 12.10 and I’m creating a FreeBSD 8.3 image using kvm



    April 15, 2013 at 12:07 pm

    • Did you fix it?



      September 13, 2013 at 4:59 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: