This is an old revision of the document!


Root On ZFS

FreeBSD can be installed to a root ZFS filesystem (/), using several different methods.

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

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 (/).

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.

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.

Installing FreeBSD Root on ZFS using a FreeBSD MBR Slice (Work in Progress)

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.

Installing FreeBSD Root on ZFS using GPT

Mirror Pool

RAIDZ1 Pool

RAIDZ2 Pool

Note about 9.0-RELEASE

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

Review the ZFS Tuning Guide for hints on tuning ZFS for FreeBSD. ZFS Tuning Guide

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.

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.

If you know of any other Root on ZFS guides, either add them here if you have access or let me know about them.

  • rootonzfs.1386801629.txt.gz
  • Last modified: 2013/12/11 22:40
  • by ScotHetzel