OpenStack – devstack – FreeBSD Image

openstack-logo5

Trying out openstack, to get a home lab up and running.
But as freebsd fan, there is no way that I’m running an openstack environment without a FreeBSD Guest VM. So time to build my own FreeBSD image to be used in a openstack environment.

Here are my “lab-notes” for build FreeBSD images.
(I’m building on a ubuntu system as a `sudo -i` user.. so no sudo in front of every cmd)

All cmd are shown in bold (could almost be run as a shell script 😉 )
Blue cmd are done on your “building host”
Red cmd are done withing the FreeBSD Guest OS

#####################################################################
## Create freebsd.img and install FreeBSD Base system
$>kvm-img create -f qcow2 freebsd.img 50G
$>kvm -m 2048 -hda freebsd.img -cdrom FreeBSD-9.1-RELEASE-amd64-bootonly.iso -boot d
$>kvm -m 2048 -hda freebsd.img -boot c

#Get corresponding virtio binary from http://people.freebsd.org/~kuriyama/virtio/
$>fetch http://people.freebsd.org/~kuriyama/virtio/9.1/virtio-kmod-9.1-0.242658.tbz
$>pkg_add virtio-kmod-9.1-0.242658.tbz

#Follow the instruction from the output (should be something like this)
#To use these modules, add loading lines in /boot/loader.conf:

virtio_load=”YES”
virtio_pci_load=”YES”
virtio_blk_load=”YES”
if_vtnet_load=”YES”
virtio_balloon_load=”YES”

#Run the following commands to and edit fstab and interface config in rc.conf:
$>sed -i.bak -Ee ‘s|/dev/ada?|/dev/vtbd|’ /etc/fstab
$>echo ‘ifconfig_vtnet0_name=”em0″‘ >> /etc/rc.conf
$>echo ‘ifconfig_em0=”DHCP”‘ >> /etc/rc.conf

## Boot FreeBSD guest os with virtio for test/check
$>kvm -drive file=freebsd2.img,if=virtio -net nic,model=virtio -net user

# Upload to image library, start an instance, and your done! 🙂
###############################################################

PS, if you did like I did, devstack all-in-one, remember to add security rules to let VM be connetable to the rest of your LAN.

Source: http://cssoss.wordpress.com/2011/11/28/bundling-freebsd-image-for-openstack/
Source: http://www.mail-archive.com/openstack@lists.launchpad.net/msg20654.html
Source: http://blog.nimbula.com/engineering/2012/09/creating-a-freebsd-9-0-machineimage-under-linux/

2 Coments

  • Michael A. Smith16/07/2013

    Looks like virtio is in ports now:

    $ uname -v && find /usr/ports -iname ‘*virtio*’ -prune
    FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
    /usr/ports/emulators/virtio-kmod

  • Building a KVM template for FreeBSD | A CloudBuilder's Notes22/08/2013

    […] http://dev.n0ll.com/2013/03/openstack-devstack-freebsd-image/ […]

  • Leave a Comments