This article covers installing FreeBSD 9.x with the root file system on ZFS with bsdinstall.
# sysctl kern.disks kern.disks: cd0 da0 da1 # gpart destroy -F da0 da0 destroyed # gpart destroy -F da1 da1 destroyed # gpart create -s VTOC8 da0 da0 created # gpart create -s VTOC8 da1 da1 created
# gpart add -s 292G -t freebsd-zfs da0 da0a added # gpart add -t freebsd-swap da0 da0b added
# gpart add -s 292G -t freebsd-zfs da1 da1a added # gpart add -t freebsd-swap da1 da1b added
Replace the 'mirror' keyword as needed, and list all disks that should be part of the pool.
# zpool create -o altroot=/mnt -O canmount=off zroot mirror da0a da1a
This will create a zpool called 'zroot' which will not be automatically mounted. The canmount property is also set to off, to avoid mounting this by accident. This zpool is only used to derive other file systems from. Now install the boot-loader on these partitions:
# zpool export zroot # gpart bootcode -p /boot/zfsboot da0 # gpart bootcode -p /boot/zfsboot da1 # sysctl kern.geom.debugflags=0x10 kern.geom.debugflags: 0 -> 16 # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc,sync 465+1 records in 466+0 records out 238592 bytes transferred in 0.244906 secs (974219 bytes/sec) # dd if=/boot/zfsloader of=/dev/da1a bs=512 oseek=1024 conv=notrunc,sync 465+1 records in 466+0 records out 238592 bytes transferred in 0.244906 secs (974219 bytes/sec) # zpool import -o altroot=/mnt zroot
The fletcher4 algorithm should be more robust than the fletcher2 algorithm.
# zfs set checksum=fletcher4 zroot # zfs set atime=off zroot
# zfs create -o mountpoint=/ zroot/ROOT
You can fine-tune and create other zfs pool: check other guide for more detailed examples.
# zpool set bootfs=zroot/ROOT zroot
# cat << EOF > /tmp/bsdinstall_etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/da0b none swap sw 0 0 /dev/da1b none swap sw 0 0 EOF
# echo 'zfs_enable="YES"' >> /etc/rc.conf # echo 'zfs_load="YES"' >> /boot/loader.conf
# zpool set cachefile=/boot/zfs/zpool.cache zroot # exit