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.
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.
tar xzf 2.2.tar.gz
make tar BASE='../dist' PKG_STATIC='/usr/local/sbin/pkg-static'(note, this needs root)
This should leave you with a
rm -rf bootto prevent old kernels or modules from getting loaded
tar xf /path/to/mfsbsd-10.3-RELEASE-amd64.tar
/boot/loader.confto set initial IP addrs and such
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.
Log in to the droplet’s console as root, and set up networking (if you didn’t change
ifconfig vtnet0 inet [addr] netmask [mask]
route add default [gateway]
echo 'nameserver 18.104.22.168' >> /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!