Installing FreeBSD 9.x Root on ZFS using VTOC8 (sparc)

This article covers installing FreeBSD 9.x with the root file system on ZFS with bsdinstall.

Note: This walkthrough assumes that a zfs mirror of two disks is created, but the instructions work equally well for a single disk or a raidz or raidz2 setup, just replace 'mirror' as needed in the examples.
  1. Boot the FreeBSD install CD/DVD.
  1. Go through the initial setup as usual.
  1. When the partitioning dialogue in bsdinstall comes up, choose the 'Shell' option.
  1. Create new VTOC8 partitioned disks, repeat this for all disks.
 # 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
  1. Add partitions for the zfs pools and swap. This example creates a 292GB partition for the ZFS, adapt to your case.
# gpart add -s 292G -t freebsd-zfs da0
da0a added
# gpart add -t freebsd-swap da0
da0b added
  1. Now duplicate this layout for each additional disk:
# gpart add -s 292G -t freebsd-zfs da1
da1a added
# gpart add -t freebsd-swap da1
da1b added
  1. Create the zfs pool.

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:

  1. Installing boot-loader.
# 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
  1. Create ZFS file system hierarchy.

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.

  1. Set booting property to this zpool
# zpool set bootfs=zroot/ROOT zroot
  1. Add the swap devices to fstab, so that they will automatically show up when the system starts.
# 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
  1. Once all of the zfs file systems have been created, type 'exit' in the shell and proceed with the installation as normal.
  1. Once the installation is complete choose 'Exit' from the main menu.
  1. The next dialogue will offer the option to 'open a shell in the new system', choose this option.
  1. Configure zfs to load and mount the file systems automatically at boot.
# echo 'zfs_enable="YES"' >> /etc/rc.conf
# echo 'zfs_load="YES"' >> /boot/loader.conf
  1. Update the zpool cache file.
# zpool set cachefile=/boot/zfs/zpool.cache   zroot
# exit
  1. To finish the installation, choose the reboot option from the dialogue, do not forget to remove the installation media from the computer.
  • rootonzfs/vtoc8zfsboot/9.x-release.txt
  • Last modified: 2013/09/13 15:58
  • by OlivierCochardLabbĂ©