This article is about how to create a FreeBSD 10.x image for use with OpenStack.The following method was tested with FreeBSD 10.2 image bundled into Liberty version of OpenStack running on Ubuntu 14.04 LTS. However this can also be used with the previous versions of OpenStack like Havana, Icehouse, Juno and Kilo.
Virtual Hard drive
Create an image needed for Hard-drive emulation
qemu-img create -f qcow2 freebsd.img 10G
FreeBSD installation
Start the Virtual Machine to boot from the CD.
kvm -m 512 -cdrom FreeBSD-10.2-RELEASE-amd64-disc1.iso -drive file=freebsd.img,if=virtio -boot d -net nic,model=virtio -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
During installation enable SSH server, IPV4 and DHCP for the interface “vtnet0”. Shutdown the Virtual Machine.
Post installation tasks
Boot the virtual from hard drive to perform the post installation tasks.
kvm -m 1024 -drive file=freebsd.img -boot c -net nic -net user -nographic -vnc :1
Verify if the following line is present in the file /etc/rc.conf. If not append it to the file.
Network configuration
ifconfig_vtnet0="DHCP"
SSH server configuration
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
Cloud-Init installation
Install Cloud-Init using the following commands
fetch --no-verify-peer https://raw.github.com/pellaeon/bsd-cloudinit-installer/master/installer.sh chmod +x installer.sh ./installer.sh
Do other necessary changes needed for the image and shutdown the Virtual Machine.
Uploading to OpenStack
Upload the image to OpenStack using the following command
glance image-create --name 'FreeBSD-10.2' --container-format bare --disk-format qcow2 --file freebsd.img --is-public True
Now you can boot instances from this image and login to the instances with the user “freebsd” using your private key.
References:
https://pellaeon.github.io/bsd-cloudinit/