This guide assumes you want to manually creating the pool, to change default settings, or to not use the entire disk. If you just want to setup ZFS on the entire disk, use the 'ZFS' option in the bsdinstall partitioning menu.
camcontrol devlist
<TOSHIBA HDWN180 GX2M> at scbus7 target 0 lun 0 (ada0,pass1)
SATA disks usually start with ada followed by a number. SAS and USB disks start with da followed by a number. The rest of this page assumes the disk is ada0; replace it with your disk device's name in all commands below.
gpart destroy ada0 gpart create -s gpt ada0
gpart add -a 4k -s 260M -t efi ada0 # Create a FAT32 partition newfs_msdos -F 32 -c 1 /dev/ada0p1 mount -t msdosfs -o longnames /dev/ada0p1 /mnt mkdir -p /mnt/EFI/BOOT cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi umount /mnt
gpart add -a 4k -s 512K -t freebsd-boot ada0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
Add some partitions for FreeBSD to use: a freebsd-swap partition and a freebsd-zfs partition.
Create the swap and zfs partitions
gpart add -a 1m -s 4G -t freebsd-swap -l swap0 ada0 gpart add -a 1m -t freebsd-zfs -l disk0 ada0
gpart show -p ada0
⇒ 40 15628053088 ada0 GPT (7.3T) 40 1024 ada0p1 freebsd-boot (512K) 1064 984 - free - (492K) 2048 4194304 ada0p2 freebsd-swap (2.0G) 4196352 15623856776 ada0p3 freebsd-zfs (7.3T)
mount -t tmpfs tmpfs /mnt
zpool create -o altroot=/mnt zroot ada0p3
The lz4 compression algorithm is fast enough to be used by default, even for incompressible data.
zfs set compress=on zroot
Create a Boot Environment hierarchy
zfs create -o mountpoint=none zroot/ROOT zfs create -o mountpoint=none zroot/ROOT/default mount -t zfs zroot/ROOT/default /mnt
Create the rest of the filesystems.
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp zfs create -o canmount=off -o mountpoint=/usr zroot/usr zfs create zroot/usr/home zfs create -o exec=off -o setuid=off zroot/usr/src zfs create zroot/usr/obj zfs create -o mountpoint=/usr/ports -o setuid=off zroot/usr/ports zfs create -o exec=off -o setuid=off zroot/usr/ports/distfiles zfs create -o exec=off -o setuid=off zroot/usr/ports/packages zfs create -o canmount=off -o mountpoint=/var zroot/var zfs create -o exec=off -o setuid=off zroot/var/audit zfs create -o exec=off -o setuid=off zroot/var/crash zfs create -o exec=off -o setuid=off zroot/var/log zfs create -o atime=on -o exec=off -o setuid=off zroot/var/mail zfs create -o exec=on -o setuid=off zroot/var/tmp
Links and Permissions
ln -s /usr/home /mnt/home chmod 1777 /mnt/var/tmp chmod 1777 /mnt/tmp
zpool set bootfs=zroot/ROOT/default zroot
cat << EOF > /tmp/bsdinstall_etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/gpt/swap0 none swap sw 0 0 EOF
exit
sysrc zfs_enable="YES" echo 'zfs_load="YES"' >> /boot/loader.conf