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) ```sh export ZFSBOOT_DISKS=ada0 export nonInteractive="YES" DISTRIBUTIONS="base.txz kernel.txz"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22

<ul>
<li>Disk:ada0</li>
<li>Device type:stripe</li>
<li>Pool name:zroot</li>
<li>Partition scheme:GPT</li>
<li>Swap size:2G</li>
<li>Mount points</li>
</ul>```
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) ```sh 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”

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

<ul>
<li>Mount points</li>
</ul>```
zroot                 none
zroot/ROOT            none
zroot/ROOT/default    /
zroot/tmp             /tmp
zroot/usr             /usr
zroot/var             /var
```<br/>
※At the time of automatic installation ZFS more information on setting, I think that it is better to check source code of the zfsboot (<a href="https://github.com/freebsd/freebsd/blob/master/usr.sbin/bsdinstall/scripts/zfsboot">freebsd/zfsboot at master · freebsd/freebsd · GitHub</a>).

</div>
</div>
<div class="section">
    ### Reference URL
    
<ul>
<li><a href="https://www.freebsd.org/cgi/man.cgi?bsdinstall%288%29">bsdinstall(8)</a></li>
<li><a href="https://github.com/freebsd/freebsd/blob/master/usr.sbin/bsdinstall/scripts/script">freebsd/script at master · freebsd/freebsd · GitHub</a></li>
<li><a href="https://github.com/freebsd/freebsd/blob/master/usr.sbin/bsdinstall/scripts/zfsboot">freebsd/zfsboot at master · freebsd/freebsd · GitHub</a></li>
<li><a href="https://groups.google.com/d/msg/fa.freebsd.stable/kg6svI6b8Fk/X-MIYF0lCEAJ">https://groups.google.com/d/msg/fa.freebsd.stable/kg6svI6b8Fk/X-MIYF0lCEAJ</a></li>
</ul><br/>
<hr/>

</div>
<div class="section">
    ### NOTE
    ※This article is a self-translation of "<a href="http://kunst1080.hatenablog.com/entry/2015/05/30/181955">bsdinstallを使ったFreeBSDの自動インストールについて[ZFS編] - くんすとの備忘録</a>".

</div>