ZFS on a FreeBSD Droplet

Recently my employer, DigitalOcean, announced FreeBSD droplets. This made me pretty happy, as I’ve been a long time fan of FreeBSD, running it on my home storage server, router, and a few other VPS providers. One of the things I would like to do though is make backups from my droplet to my home storage server as easy as possible. For me, this meant ZFS snapshots and being able to send snapshot diffs between systems.

Since the droplets default to UFS, the first hurdle was reinstalling the system onto a ZFS root, which turns out to be relatively simple.

Here’s how I did it. This all assumes a fresh blank FreeBSD droplet, and will delete everything on the droplet in the process.

Update 6-Oct-2015: Finally updated this for FreeBSD 10.2!

Update 7-Apr-2016: Updated for FreeBSD 10.3-RELEASE.

Create mfsBSD tarball

The key to all this is being able to boot into a memory filesystem in order to reformat the droplet’s drive, and the easiest way to do that is to use mfsBSD.

Extract tarball over / and reboot

cd /

rm -rf boot to prevent old kernels or modules from getting loaded

tar xf /path/to/mfsbsd-10.3-RELEASE-amd64.tar

(optional) edit /boot/loader.conf to set initial IP addrs and such

reboot

After this point, you’ll want to be on the droplet’s console. It should reboot into the mfsBSD environment. If you didn’t edit loader.conf then you’ll need to manually configure vtnet0 for Internet access.

Install

Log in to the droplet’s console as root, and set up networking (if you didn’t change loader.conf)

ifconfig vtnet0 inet [addr] netmask [mask]

route add default [gateway]

echo 'nameserver 8.8.8.8' >> /etc/resolv.conf

At this point you should be able to just run bsdinstall and do a regular FreeBSD installation onto vtblk0, selecting ZFS when it comes to paritioning the disk.

When the install is done, just reboot again and you’ll have a nice clean ZFS droplet!