Building FreeBSD cloudinit images for Terraform

Setting up FreeBSD to run cloudinit to make custom images is pretty easy.

The first step is to boot a basic image or the install ISO and install FreeBSD. Once it is up and running then install cloudinit:

pkg install net/cloud-init

And enable cloudinit:

sysrc cloudinit_enable=YES

Currently there is a bug in cloud-init where it does not try to mount the correct filesystem with the correct type on FreeBSD. It tries to use the old outdated vfat type, instead of mosdosfs.

I have opened FreeBSD Bug 250496 which contains the patch to fix this bug. If the bug is still open when you read this, you probably need to manually apply the diff in the bug. Thankfully cloudinit is written in Python so it is easy to apply the patch directly to the installed package.

At this point it might be advantageous to apply any existing security updates via FreeBSD Update:

freebsd-update fetch install

Make any final modifications to the image, note I do not recommend installing any other software as that should be done via cloudinit from this point forward.

Then shut it down:


Then convert the image to a template.