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 10.10.10.1 is the IP address of the host machine.
vncviewer 10.10.10.1 :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.
virtio_load="YES" virtio_pci_load="YES" virtio_blk_load="YES" if_vtnet_load="YES" virtio_balloon_load="YES"
For enabling DHCP for Virtio NIC , add the following line to /etc/rc.conf
ifconfig_vtnet0="DHCP"
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.
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.