**Warning**
This document is largely outdated, and is preserved to serve as documentation for existing installations.
Start with the %%FreeBSD%% Handbook's [[https://docs.freebsd.org/en/books/handbook/zfs/|ZFS Chapter]] if you have not read it yet. For instructions on how to install root on ZFS, please see the %%FreeBSD%% Handbook's [[https://docs.freebsd.org/en/books/handbook/bsdinstall/|Installation chapter]].
====== Root On ZFS ======
%%FreeBSD%% can be installed to a root [[ZFS]] filesystem (/), using several different methods.
===== 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
==== Using MBR Disk ====
The advantage of using a MBR disk is that you can still dual boot with other Operating Systems.
=== UFS /boot ===
This installation boots %%FreeBSD%% from UFS filesystem /boot filesystem, and then mounts %%FreeBSD%%-ZFS partition as the root filesystem (/).
[[RootOnZFS/UFSBoot|Installing FreeBSD Root on ZFS using UFS /boot]]
=== 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.
[[RootOnZFS/ZFSBootPartition|Installing FreeBSD Root on ZFS using FreeBSD-ZFS partition in a FreeBSD MBR Slice]]
=== 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.
[[RootOnZFS/ZFSBootSlice|Installing FreeBSD Root on ZFS using a FreeBSD MBR Slice]] (Work in Progress)
==== 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.
=== 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.
[[RootOnZFS/GPTZFSBoot|Installing FreeBSD Root on ZFS using GPT]]
=== Mirror Pool ===
[[RootOnZFS/GPTZFSBoot/Mirror|Installing FreeBSD Root on ZFS (Mirror) using GPT]]
=== RAIDZ1 Pool ===
[[RootOnZFS/GPTZFSBoot/RAIDZ1|Installing FreeBSD Root on ZFS (RAIDZ1) using GPT]]
=== RAIDZ2 Pool ===
[[RootOnZFS/GPTZFSBoot/RAIDZ2|Installing FreeBSD Root on ZFS (RAIDZ2) using GPT]]
=== Note about 9.0-RELEASE ===
[[RootOnZFS/GPTZFSBoot/9.0-RELEASE|Installing FreeBSD 9.0-RELEASE Root on ZFS (Mirror) using GPT]]
==== Using VTOC8 Disk (sparc64) ====
For booting a sparc64 arch, the installation procedure of the boot-loader needs to be customized:
[[RootOnZFS/VTOC8ZFSBoot/9.x-RELEASE|Installing FreeBSD 9.x-RELEASE Root on ZFS (Mirror) using VTOC8]]
===== ZFS Tips =====
==== ZFS Tuning Guide ====
Review the ZFS Tuning Guide for hints on tuning ZFS for %%FreeBSD%%.
[[ZFSTuningGuide|ZFS Tuning Guide]]
==== 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.
==== 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.
===== Other Root on ZFS guides =====
* [[ZFSOnRoot|Root on ZFS configuration with UFS /boot]] by AndrewThompson
* [[http://blogs.freebsdish.org/lulf/2008/12/16/setting-up-a-zfs-only-system/|Root on ZFS configuration (gptzfsboot)]] by UlfLilleengen
* [[http://www.keltia.net/howtos/zfsroot-freebsd8/|GPT Mirror and RAIDZ1 ZFS-only boot]] by OllivierRobert
* [[http://www.keltia.net/howtos/mfsbsd-zfs91/|9.1 GPT/GELI/Mirror/RAIDZ1 ZFS-only boot]] by OllivierRobert
* [[http://www.leidinger.net/blog/2011/05/03/another-root-on-zfs-howto-optimized-for-4k-sector-drives/|Another root-on-zfs HOWTO (optiĀmized for 4k-sector drives)]] by AlexanderLeidinger
* [[http://anonsvn.h3q.com/projects/freebsd-patches/wiki/manageBE|manageBE]] by Philipp Wuensche
* [[http://forums.freebsd.org/showthread.php?t=31662|sysutils/beadm]] by vermaden - Solaris Live-Update like boot-environment implementation for %%FreeBSD%%
* [[http://web.mr-happy.com/hackstuff/FreeBSD-ZFS.php|ZFS-Only FreeBSD]] by Jeff Blank
* [[ZFSOnRootWithZFSboot|Root on ZFS configuration (zfsboot)]] by ScotHetzel (depreciated)
* [[http://julipedia.meroh.net/2013/07/installing-freebsd-with-zfs-root-on.html|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.