bsdinstall scripted zfs install

mike tancsa mike at
Wed Jun 2 18:37:27 UTC 2021

I have been experimenting with bsdinstall and scripted installs.  I can
get everything to work just fine on UFS installs, but zfs seems to fail,
even with minimal configs. I am testing on RELENG13, and trying to make
a 12.2R image.

I do a

truncate -s 20G test.img

mdconfig -o async -f test.img


bsdinstall script zfsinstall.cfg

zfsinstall.cfg has in it

export DISTRIBUTIONS="kernel.txz base.txz homes.tgz lib32.txz"
export ZFSBOOT_POOL_NAME="zrootmdt2"
export ZFSBOOT_DISKS="md0"
export ZFSBOOT_POOL_CREATE_OPTIONS="-d -O compress=lz4  -o
feature at lz4_compress=enabled -o cachefile=/var/tmp/zpool.cache"
export nonInteractive="YES"
export nonInteractive=0 bsdinstall zfsboot

echo 'Running installerconfig...'
export PACKAGESITE="pkg+${ABI}/latest"
sysrc ifconfig_igb0=DHCP
sysrc sshd_enable=YES
# Installing packages. The following two lines is borrowed
# code from sysutils/firstboot-pkgs [1]

env PACKAGESITE="pkg+${ABI}/latest"
env ASSUME_ALWAYS_YES=YES pkg bootstrap -f | cat

pkg install -y frr7 nrpe3 sudo
#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 md0


It creates the zfs pool, but then fails with

Error mounting partition /mnt/boot/efi:  
mount_msdosfs: /dev/md0p1: Device busy

before it even gets to running the dist extraction.  It also unmounts my
live zfs working set,

Filesystem                          1K-blocks      Used      Avail
Capacity  Mounted on
ryz13root/ROOT/default              117085016  37382900   79702116   
32%    /
devfs                                       1         1          0  
100%    /dev 9346203520 170623120 9175580400    
2%    /nfsmount
zrootmdt/ROOT/default                 1569504       316    1569188    
0%    /mnt
zrootmdt/tmp                          1569332       144    1569188    
0%    /mnt/tmp
zrootmdt/usr/home                     1569332       144    1569188    
0%    /mnt/usr/home
zrootmdt/usr/ports                    1569332       144    1569188    
0%    /mnt/usr/ports
zrootmdt/usr/src                      1569332       144    1569188    
0%    /mnt/usr/src
zrootmdt/var/audit                    1569332       144    1569188    
0%    /mnt/var/audit
zrootmdt/var/crash                    1569332       144    1569188    
0%    /mnt/var/crash
zrootmdt/var/log                      1569332       144    1569188    
0%    /mnt/var/log
zrootmdt/var/mail                     1569332       144    1569188    
0%    /mnt/var/mail
zrootmdt/var/tmp                      1569332       144    1569188    
0%    /mnt/var/tmp
zrootmdt                              1569332       144    1569188    
0%    /mnt/zrootmdt
/dev/md0p1                             266176        32     266144    
0%    /mnt/boot/efi
root at coldstorage2:/work #

so in this case I have to do a
umount /mnt/boot/efi
zfs export zrootmdt
zfs mount -a

to get back my proper file system

Any idea what I am doing wrong ?

Last few lines on the log file just show

DEBUG: f_variable_set_defaults: Defaults initialized.
DEBUG: variable.subr: Successfully loaded.
DEBUG: f_include_lang:
file=[/usr/libexec/bsdconfig/include/messages.subr] lang=[C.UTF-8]
DEBUG: f_dialog_init: ARGV=[installer-zfs.cfg] GETOPTS_STDARGS=[dD:SX]
DEBUG: f_dialog_init: SECURE=[] USE_XDIALOG=[]
DEBUG: f_dialog_init: dialog(1) API initialized.
DEBUG: dialog.subr: Successfully loaded.
DEBUG: f_include: file=[/usr/share/bsdconfig/variable.subr]
DEBUG: Began Installation at Wed Jun  2 14:34:41 EDT 2021

More information about the freebsd-questions mailing list