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.
fetch https://github.com/mmatuska/mfsbsd/archive/2.2.tar.gz
tar xzf 2.2.tar.gz
mkdir dist
cd dist
fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.3-RELEASE/base.txz
fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.3-RELEASE/kernel.txz
cd ../mfsbsd-2.2
make tar BASE='../dist' PKG_STATIC='/usr/local/sbin/pkg-static'
(note, this needs root)This should leave you with a mfsbsd-10.3-RELEASE-amd64.tar
cd /
rm -rf boot
to prevent old kernels or modules from getting loadedtar xf /path/to/mfsbsd-10.3-RELEASE-amd64.tar
/boot/loader.conf
to set initial IP addrs and suchreboot
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 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!