BSD · Cloud · FreeBSD · Image Management · KVM · Open source · OpenSSH · OpenStack · sshd · Ubuntu

Bundling FreeBSD 9.x image for OpenStack

The following method was tested with FreeBSD 9.1 image bundled into Grizzly version of OpenStack running on Ubuntu 12.04

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 512 -cdrom FreeBSD-9.1-RELEASE-amd64-dvd1.iso -drive file=freebsd.img -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

For partitioning table option select GPT. After installation is over, during the post-installation configuration enable SSH server, IPV4  and DHCP.

Shutdown the Virtual Machine and  use the following command to boot from the hard drive.

kvm -m 1024 -drive file=freebsd.img -boot c -net nic -net user -nographic -vnc :1

Perform the following steps for installing and configuring Virtio.

Download the compressed snapshot of the ports collection.

portsnap fetch

Now extract the snapshot into /usr/ports.

portsnap extract

Install virtio modules using the following commands.

cd /usr/ports/emulators/virtio-kmod
make install
make clean

Add the following lines to /boot/loader.conf.


For enabling DHCP for Virtio NIC , add the following line to /etc/rc.conf


Do the other necessary changes needed for the image and shutdown the Virtual Machine.

To make sure the Virtio modules are loaded, we need to boot the Virtual Machine with another hard disk.

Create another disk with 2GB capacity.

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

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

kvm -m 512 -drive file=freebsd.img -drive file=test.img,if=virtio -boot c -net nic -net user

To check if the driver is loaded, use the following command.

dmesg |grep -i virtio

We need to change the /etc/fstab file as the primary Hard drive is referred to, using a different name in FreeBSD like “/dev/vtbd0p1”.

Backup the /etc/fstab file

cp /etc/fstab /etc/fstab.bak

Edit the file /etc/fstab and replace the letters “ada” with “vtbd”.

For example if the device is “/dev/ada0p2” then replace it as “/dev/vtbd0p2”

The file will look like this

# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/vtbd0p2    /               ufs     rw      1       1
/dev/vtbd0p3    none            swap    sw      0       0

Edit the following lines as below in /etc/ssh/sshd_config, 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 Horizon or Glance commands.

One thought on “Bundling FreeBSD 9.x image for OpenStack

  1. I don’t know what about you, but for me installation took around 4 hours. I don’t thing it’s really good idea to do this for everyone. It’s better just to share an image or something… cause this is not funny I’d say.

Leave a Reply

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

You are commenting using your 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