Install FreeBSD 11 on ZFS mirror (GPT or MBR)

Finish installation

by ross at 04:52:51 on October 23, 2017

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. Have a look at Initial configuration article.

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
-- 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
Oh my god i did it! U r my sensei! Thanks a lot!
-- Sergey Belkin
Sunday, December 10, 2017, 23:56:49
Hi, ross

Help plz.
I did every step of GPT way.
But bootable device not found after reboot.

How can I fix it? Any idea?

-- Konstantin
Wednesday, March 21, 2018, 9:05:48
Are you sure you have created freebsd-boot partition and installed bootcode to it, just like here ?

parameter -i to the "gpart bootcode" command is actually the partition number
-- ross
Wednesday, March 21, 2018, 13:45:35
Yes, I did it.
I have active EFI. Could it possible reason for my fail?
-- Konstantin
Thursday, March 22, 2018, 14:41:19
these commands for MBR or for both GPT and MBR?
-- Konstantin
Thursday, March 22, 2018, 14:42:53
I meant:

# dd if=/boot/zfsboot of=/dev/ada1s1 count=1
# dd if=/boot/zfsboot of=/dev/ada1s1a skip=1 seek=1024
# dd if=/boot/zfsboot of=/dev/ada2s1 count=1
# dd if=/boot/zfsboot of=/dev/ada2s1a skip=1 seek=1024
-- Konstantin
Thursday, March 22, 2018, 14:43:31
this is for mbr.

the problem is efi, I believe. you can try to enable legacy boot.

all my systems still use bios, but I should probably update the guide to uefi some day...
-- ross
Saturday, March 24, 2018, 8:04:11