Now, we take a look at how to install to ZFS using bsdinstall.

Installation of ZFS in an auto layout

As it is described in the manual, to the first half (PREAMBLE), if describe the environment variable “ZFSBOOT_DISKS” instead of “PARTITIONS”, ZFS allows you to install to.However, care must be taken of the following two points.

  • If you want to automatically install, set environment variable _"nonInteractive"_.
  • It needs to be _export_ environment variables _"ZFSBOOT_DISKS"_ and _"nonInteractive"_.
In particular, care must be taken with regard to the second point.(I tried to read freebsd/script at master · freebsd/freebsd · GitHub, I am feeling that because DISTRIBUTIONS has been _export_, but such _ZFSBOOT_DISKS_ has not been _export_, ...... and it is the cause)

First half (PREAMBLE)

1
2
3
4
export ZFSBOOT_DISKS=ada0
export nonInteractive="YES"
DISTRIBUTIONS="base.txz kernel.txz"

In the above configuration, ZFS partition has been created by default setting.

  • Disk:ada0
  • Device type:stripe
  • Pool name:zroot
  • Partition scheme:GPT
  • Swap size:2G
  • Mount points
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
zroot                 none
zroot/ROOT            none
zroot/ROOT/default    /
zroot/tmp             /tmp
zroot/usr             /usr
zroot/usr/home        /usr/home
zroot/usr/ports       /usr/home
zroot/usr/src         /usr/home
zroot/var             /var
zroot/var/crash       /var/crash
zroot/var/log         /var/log
zroot/var/mail        /var/mail
zroot/var/tmp         /var/tmp

Installation of ZFS in a custom layout

Set environment variable “ZFSBOOT_DATASETS”, it seems that you can create a ZFS layout freely.For now, we will try to split /, /tmp, /usr, /var.

First half (PREAMBLE)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
export ZFSBOOT_DISKS=ada0
export ZFSBOOT_DATASETS="
    /ROOT                mountpoint=none
    /ROOT/default        mountpoint=/

    /tmp        mountpoint=/tmp,exec=on,setuid=off
    /usr        mountpoint=/usr,canmount=off
    /var        mountpoint=/var,canmount=off
" 
export nonInteractive="YES"
DISTRIBUTIONS="base.txz kernel.txz"

In the above configuration, ZFS partition has been created with the following settings.

  • Mount points
1
2
3
4
5
6
zroot                 none
zroot/ROOT            none
zroot/ROOT/default    /
zroot/tmp             /tmp
zroot/usr             /usr
zroot/var             /var

※At the time of automatic installation ZFS more information on setting, I think that it is better to check source code of the zfsboot (freebsd/zfsboot at master · freebsd/freebsd · GitHub).

Reference URL



NOTE

※This article is a self-translation of “bsdinstallを使ったFreeBSDの自動インストールについて[ZFS編] - くんすとの備忘録”.