Install FreeBSD 11 on ZFS mirror (GPT or MBR)

Finish installation

by ross at 03:29:54 on October 25, 2016

On the last installation screen choose shell again when asked.

Create system init configs

# echo 'zfs_load="YES"' >> /boot/loader.conf
# echo 'vfs.root.mountfrom="zfs:system"' >> /boot/loader.conf
# echo 'zfs_enable="YES"' >> /etc/rc.conf

Create fstab file

/etc/fstab (GPT)

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/cd0                /media/cdrom    cd9660  ro,noauto       0       0
/dev/da0s1              /media/flash    msdosfs rw,sync,noauto,longnames,-Lru_RU.UTF-8 0 0
/dev/ufs/share          /share          ufs     rw              1       2

/etc/fstab (MBR)

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/cd0                /media/cdrom    cd9660  ro,noauto       0       0
/dev/da0s1              /media/flash    msdosfs rw,sync,noauto,longnames,-Lru_RU.UTF-8 0 0
/dev/ufs/share          /share          ufs     rw              1       2

ZFS filesystems does not need fstab entries. Adjust flash mount options as you want.

Create mount points:

# cd /media
# mkdir cdrom flash
# cd /
# mkdir share

I have only one UFS filesystem — /share. If you don't have any then skip the step. Or create mountpoints and fstab entries for filesystems you have.

Note that I use /dev/ufs/share as the device. If your UFS2 filesystem does not have a label than it's time to create one:

# tunefs -L share /dev/ada3s1d

Reboot into your new system

Type exit, finish the installation and reboot. Set BIOS to boot from one of the mirrored drives.

Login to the system and:

# zfs set readonly=on system/var/empty
# rm /etc/motd

Create swap (eight gigabytes here — change it):

# zfs create -V 8G -o org.freebsd:swap=on -o checksum=off -o compression=off \
  -o dedup=off -o sync=disabled -o primarycache=none system/swap
# swapon /dev/zvol/system/swap

Now you can start configuring your new system.

Comments
Hi ross,

It didn't work for me.
First the boot loader wouldn't find the right partition to boot from. It searches on the second partition which is the swap.
If I manually enter the root partition and there the kernel it freezes.
If I boot with the installation usb stick I can see the pools I created but they are all faulty.
If I do a "zpool status" I see that they are still refering to xxx.nop devices which do not exist after reboot.
If I recreate the "nop" device I can use the pool.
Probably that is the cause of all problems and I don't know how to fix it.
-- erdelyi4
Sunday, February 2, 2014, 15:46:40
Thanks
-- AP
Friday, April 4, 2014, 1:12:32
Nice howto. Everything went fine for me. Thanks a lot!
-- Sébastien RICCIO
Saturday, March 28, 2015, 4:12:19
Very well written. It has worked perfectly for me and now this is my favourite when I do a ZFS mirror install.
-- Eva
Sunday, August 9, 2015, 15:11:30