Bundling FreeBSD 8.2 image for OpenStack

The following method was tested with FreeBSD 8.2 image bundled into Diablo version of OpenStack. The OpenStack cloud was setup using the procedure given in the following link.


Create a raw image which emulates the Hard Drive.

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

Start the Virtual Machine to 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

After installation is over, during the post-installation configuration enable SSH server. Also enable dhcp for the interface re0.

Shutdown the Virtual Machine and  start it 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

Now extract the snapshot into /usr/ports.

portsnap extract

Also download the kernel source using the following steps.
Run the command.


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.


Now the installation and configuration of the virtio driver is over. Do the other necessary changes needed for the image and shutdown the Virtual Machine.

In order to check the driver installed boot the Virtual Machine with another hard disk.For checking first create another disk with 2GB capacity.

kvm-img create -f qcow2 test.img 2G

Boot the Virtual Machine created by attaching the newly created disk to it.

kvm -m 256 -drive file=freebsd.img,if=scsi,index=0,boot=on -drive file=test.img,if=virtio,index=0 -boot c -net nic -net user

To check if the driver is loaded properly use the command.

dmesg |grep -i virtio

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

Edit the lines for SSH access as root and to enable password authentication.

PermitRootLogin yes
PasswordAuthentication yes

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

cloud-publish-image amd64 freebsd.img freebsdbucket

1 http://viktorpetersson.com/2011/10/20/how-to-use-virtio-on-freebsd-8-2/
2 http://www.cyberciti.biz/faq/freebsd-install-kernel-source-code/

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