Warning This document is largely outdated, and is preserved to serve as documentation for existing installations.
Start with the FreeBSD Handbook's ZFS Chapter if you have not read it yet. For instructions on how to install root on ZFS, please see the FreeBSD Handbook's Installation chapter.
Root On ZFS
FreeBSD can be installed to a root ZFS filesystem (/), using several different methods.
Contents
1. Root on ZFS
FreeBSD can boot from a ZFS root using either a MBR formated disk or GPT formated disk.
Requirements:
FreeBSD install image that contains the Livefs Fixit environment:- 8.0-RELEASE-{arch}-dvd1.iso
- 8.0-RELEASE-{arch}-memstick.img
1.1. Using MBR Disk
- The advantage of using a MBR disk is that you can still dual boot with other Operating Systems.
1.1.1. UFS /boot
- This installation boots FreeBSD from UFS filesystem /boot filesystem, and then mounts FreeBSD-ZFS partition as the root filesystem (/).
1.1.2. FreeBSD-ZFS partition in a FreeBSD MBR Slice
- This installation boots FreeBSD directly from the FreeBSD-ZFS root filesystem (/). This installation requires the creation of a MBR formated disk. The FreeBSD-ZFS partition is then created inside a FreeBSD slice. To boot from the FreeBSD-ZFS root filesystem requires the installation of zfsboot bootcode on the FreeBSD slice and FreeBSD-ZFS partition. It will also require the installation of a ZFS aware /boot/loader.
Installing FreeBSD Root on ZFS using FreeBSD-ZFS partition in a FreeBSD MBR Slice
1.1.3. FreeBSD MBR slice
- This installation boots FreeBSD directly from the FreeBSD-ZFS root filesystem (/). This installation requires the creation of a MBR formated disk. A FreeBSD filesystem is then created using a FreeBSD slice. To boot from the FreeBSD-ZFS root filesystem requires the installation of zfsboot bootcode on the slice. It will also require the installation of a ZFS aware /boot/loader.
Installing FreeBSD Root on ZFS using a FreeBSD MBR Slice (Work in Progress)
1.2. Using GPT Disk
- The disadvantage of using a GPT disk is that you can't dual boot other Operating Systems using the /boot/pmbr and /boot/gptzfsboot code. You may be able to boot multiple Operating Systems using a GPT aware Grub or Grub2 setup and a Hybrid GPT/MBR Installation.
1.2.1. Single Disk Pool
- This installation boots FreeBSD from the a GPT disk. This installation requires the creation of a GPT formated disk, FreeBSD-Boot partition and FreeBSD-ZFS partition. To boot from the FreeBSD-ZFS partition, requires the installation of gptzfsboot into the FreeBSD-Boot partition.
1.2.2. Mirror Pool
1.2.3. RAIDZ1 Pool
1.2.4. RAIDZ2 Pool
1.2.5. Note about 9.0-RELEASE
1.3. Using VTOC8 Disk (sparc64)
- For booting a sparc64 arch, the installation procedure of the boot-loader needs to be customized:
Installing FreeBSD 9.x-RELEASE Root on ZFS (Mirror) using VTOC8
2. ZFS Tips
2.1. ZFS Tuning Guide
- Review the ZFS Tuning Guide for hints on tuning ZFS for FreeBSD.
2.2. ZFS Swap Volume
- Creating a swap partition on the ZFS Filesystem using a ZFS Volume:
Fixit# zfs create -V 2G -o org.freebsd:swap=on -o checksum=off -o compression=off -o dedup=off -o sync=disabled -o primarycache=none zroot/swap
Note:
If there is no real memory available, the system might become unresponsive. To help mitigate this, consider raising the value of vm.v_free_severe (as well as vm.v_free_min and vm.v_free_target such that v_free_severe < v_free_min < v_free_target). For instance, on a system with 3GB of RAM, JohnNielsen was able to prevent a reproducible out-of-memory hang by setting vm.v_free_severe=7168.
2.3. Alternate /etc/fstab
Instead of using vfs.root.mountfrom and setting mount points for /tmp, /usr and /var, create an /etc/fstab to mount each of the ZFS filesystems. Using the example ZFS Filesystem created in this guide, the /etc/fstab would be:
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s3b none swap sw 0 0 zroot / zfs rw,noatime 0 0 zroot/tmp /tmp zfs rw,noatime 0 0 zroot/usr /usr zfs rw,noatime 0 0 zroot/usr/home /usr/home zfs rw,noatime 0 0 zroot/usr/ports /usr/ports zfs rw,noatime 0 0 zroot/usr/ports/distfiles /usr/ports/distfiles zfs rw,noatime 0 0 zroot/usr/ports/packages /usr/ports/packages zfs rw,noatime 0 0 zroot/usr/src /usr/src zfs rw,noatime 0 0 zroot/var /var zfs rw,noatime 0 0 zroot/var/crash /var/crash zfs rw,noatime 0 0 zroot/var/db /var/db zfs rw,noatime 0 0 zroot/var/db/pkg /var/db/pkg zfs rw,noatime 0 0 zroot/var/empty /var/empty zfs ro 0 0 zroot/var/log /var/log zfs rw,noatime 0 0 zroot/var/mail /var/mail zfs rw,noatime 0 0 zroot/var/run /var/run zfs rw,noatime 0 0 zroot/var/tmp /var/tmp zfs rw,noatime 0 0
NOTE: Since zroot has it's mountpoint set to legacy, any zfs filesystem created on zroot will need to either be added to /etc/fstab or have it's mountpoint set.
3. Other Root on ZFS guides
Another root-on-zfs HOWTO (optiĀmized for 4k-sector drives) by AlexanderLeidinger
manageBE by Philipp Wuensche
sysutils/beadm by vermaden - Solaris Live-Update like boot-environment implementation for FreeBSD
ZFS-Only FreeBSD by Jeff Blank
Root on ZFS configuration (zfsboot) by ScotHetzel (depreciated)
Installing FreeBSD with a ZFS root on a PowerMac G5 by JulioMerino
If you know of any other Root on ZFS guides, either add them here if you have access or let me know about them.