zfsboot  How to install FreeBSD on a ZFS system 'root' partition


ZFS — the breakthrough file system in FreeBSD 7 (ported from Sun's Solaris 10 Operating System) delivers virtually unlimited capacity, provable data integrity, and near-zero administration. However, FreeBSD's sysinstall(8) does not yet support installing the system onto anything more exotic than a commonly used UFS partition scheme. Furthermore, FreeBSD's boot loader(8) cannot yet load the kernel and modules from ZFS.


Install FreeBSD onto a bootable USB flash drive along with a copy of the zfsboot script on it. Boot from the USB flash drive and run the zfsboot script. This usbinstall script can be used to prepare a bootable USB drive.


The zfsboot script presented here will create the regular bootable 'a' partition, but configure it as RAID-1 using gmirror(8). This approach provides the possibility to directly boot from any of the drives by configuring the BIOS boot order. This works even if only one drive is used, although gmirror(8) will not be doing any mirroring. See Ralf S. Engelschall's <rse@FreeBSD.org> excellent System Disk Mirroring HOWTO and note the implementation here is using GEOM mirror on partitions of a slice on a disk for the boot partition.

Since we're forced to use a regular 'a' boot partition there is some advntage in using a regular 'b' partion for swap. Due to the way ZFS is currently implemented there is a known issue (in FreeBSD and OpenSolaris) where ZFS needs to allocate memory to send an I/O request. When there is no memory, ZFS cannot allocate any and thus cannot swap a process out and free it. Such low memory conditions can cause the machine to effectively freeze — unable to swap out to disk right when it is most crucial to do so. See http://Lists.FreeBSD.org/pipermail/freebsd-current/2007-September/076831.html

The script assumes the FreeBSD 8 disk1 ISO to be mounted on /dist on another host and /root/.ssh/authorized_keys on that host should allow the target machine booted via the usb drive to connect without requiring a password.

ZFS filesystem definition file should be a variation of the zfsboot.fs modified to suit your needs.


All of the zfsboot scripts and config files can be found here.


See the following links for further details: