Background: I’ve been using Debian for the last years on my server. Debian was always easy to upgrade, but there is no option to have ZFS running natively on the server with still out-of-the-box upgrades.

Furthermore my services were running in vmware server, a product that was easy to run at the time, but getting IPv6 support correctly working was not my idea of fun.

So I looked into FreeBSD and started to get the hang on it’s jails system. Esp. with ZFS. I showed it a friend of mine how easy it is and showed him the installation on my desktop Mac inside virtual machine.

I got stuck with selecting ZFS as root filesystem. There was no option for that ! I wondered and found out later, that the option to select ZFS as root was something my hosting service (hetzner) added to their FreeBSD setup routine.

The documentation I found (on how to install root on zfs) on the interwebs was inadequate. Some installation instructions were using commands not even needed any more , so that I created my own manual:

First: Download freebsd disk1 image, boot from that image.

Select 2 for single user boot.

Setup the partition table:

gpart create -s gpt da0										# creates gpt partition table on device da0
gpart add -s 64k -t freebsd-boot da0						# creates partition for bootloader size 64 kBytes
gpart add -t freebsd-zfs da0								# create zfs partition for the rest of the drive
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0 	# write zfsbootloader to boot partition 1, adding virtual master boot loader for systems that can't boot from gpt

Setup ZFS. I’m creating a zroot/9.2 for the root directory, so we can have the next FreeBSD version 10.0 as separate zfs dataset later, when that is released.

zpool create -o altroot=/mnt -O mountpoint=none zroot /dev/da0p2	# create zfs pool named zroot on partition 2
zfs create -o mountpoint=/ zroot/9.2 								# create zfs dataset root in pool 
zfs create zroot/9.2/var
zfs create zroot/9.2/tmp
zpool set bootfs=zroot/9.2 zroot

After setting up ZFS, just copy over the system needed files:

cd /mnt													
for i in base kernel lib32				# untar kernel base system and libraries
do
tar -zxpf /usr/freebsd-dist/$i.txz
done

Setting up our new machine so that it loads the zfs kernel module

echo 'zfs_load="YES"' >/mnt/boot/loader.conf	# this tells the loader to load the zfs kernel module.
echo 'zfs_enable="YES"' >/mnt/etc/rc.conf		# this will start automounting zfs filesystems other than root

From here on you can setup your network configuration or root password, but the core os should run:

reboot