Claus Andersen wrote on 05/19/2015 11:06:> Hi, > > Got no answer on -questions so I hope I do not break netiquette by > trying my luck here: > > I cannot wrap my head around this: Am able to do an unattended install > using bsdinstall and UFS on 10.1. But I cannot get ZFS to work unattended. > If I set the variables concerning ZFS in the install script they do not > seem to get picked up. If I set them on the command line using export > before I execute the script it only picks up on ZFSBOOT_* but seems to > ignore ZFSINTERACTIVE and ZFS_CONFIRM_LAYOUT > > This almost works: > # ZFSBOOT_DISKS="da0 da1" > # ZFSBOOT_VDEV_TYPE="mirror" > # ZFSBOOT_CONFIRM_LAYOUT=0 > # export ZFSBOOT_DISKS ZFSBOOT_VDEV_TYPE ZFSBOOT_CONFIRM_LAYOUT > # bsdinstall script install.txt > > But this still gives me the menu "ZFS Configuration". In the menu I can > see that it has picked up ZFSBOOT_DISKS and ZFSBOOT_VDEV_TYPE. > > The minimal "install.txt" contains: > > DISTRIBUTIONS="kernel.txz base.txz" > RELEASE="10.1" > ZFSINTERACTIVE="NO" > > #!/bin/sh > echo "Installation complete, running in host system" > > It seems to ignore ZFSINTERACTIVE. I have tried with 0, "0", "false", > "False", "FALSE". And I have tried going the export route. > > I would rather use whatever bsdinstall makes available so I can retire my > current range of DIY scripts. > > What is the correct(TM) way of doing unattended install using bsdinstall > and ZFS? Google and the man page was not enough for me - I need a real > human being!I didn't use bsdinstall script, but I look in to code and I think you should not set ZFSINTERACTIVE at all (or leave it empty?). If it is set, you get Interactive install. You just need to set NONINTERACTIVE This is the code used by bsdinstall and there are useful comments: /usr/share/bsdconfig/variable.subr # f_zfsinteractive # # Has the user specifically requested the ZFS-portion of configuration and # setup to be performed interactively? Returns success if the user has asked # for the ZFS configuration to be done interactively even if perhaps overall # non-interactive mode has been requested (by setting nonInteractive). # # Returns success if $zfsInteractive is set and non-NULL. # f_zfsinteractive() { local value f_getvar $VAR_ZFSINTERACTIVE value && [ "$value" ] } # f_interactive # # Are we running interactively? Return error if $nonInteractive is set and non- # NULL, otherwise return success. # f_interactive() { local value ! f_getvar $VAR_NONINTERACTIVE value || [ ! "$value" ] } Take a closer look in to /usr/share/bsdconfig/variable.subr Miroslav Lachman
On Tue, 19 May 2015, Miroslav Lachman wrote:> I didn't use bsdinstall script, but I look in to code and I think you should > not set ZFSINTERACTIVE at all (or leave it empty?). > If it is set, you get Interactive install. > > You just need to set NONINTERACTIVEThanks! This makes sense - but does not work for me. I have tried to set NONINTERACTIVE but I get the same result: The "ZFS Configuration" dialog. On a side note I would expect NONINTERACTIVE to be set in "script" - but I digress. When I follow the source as you suggest I see: /usr/libexec/bsdinstall/script calls "bsdinstall zfsboot" because ZFSBOOT_DISKS is set. Looking in /usr/libexec/bsdinstall/zfsboot the interesting bit here seems to be: # # If interactive and the user has not explicitly chosen a vdev type or disks, # make the user confirm scripted/default choices when proceeding to install. # : ${ZFSBOOT_CONFIRM_LAYOUT:=1} But I have set both vdev type and disks. I have even tried setting ZFSBOOT_CONFIRM_LAYOUT=0 - but most of my tests are without setting this. And this seems to control a later confimation step - and not the initial "ZFS Configuration" dialog. This bit kills me if I have ZFSINTERACTIVE set. But I have not (anymore): # User may have specifically requested ZFS-related operations be interactive ! f_interactive && f_zfsinteractive && unset $VAR_NONINTERACTIVE So when I examine the code with my limited capabilities everything looks correct. But it still fails for me. I do the following in a new clean and pristine VM booting the 10.1 CD. # export ZFSBOOT_DISKS="da0 da1" # export ZFSBOOT_VDEV_TYPE="mirror" # bsdinstall script install.txt But this still gives me the menu "ZFS Configuration". In the menu I can see that it has picked up ZFSBOOT_DISKS and ZFSBOOT_VDEV_TYPE. I have tried the following invariant: # export ZFSBOOT_DISKS="da0 da1" # export ZFSBOOT_VDEV_TYPE="mirror" # export NONINTERACTIVE="YES" # bsdinstall script install.txt With the same result. The minimal "install.txt" contains: DISTRIBUTIONS="kernel.txz base.txz" RELEASE="10.1" NONINTERACTIVE="YES" #!/bin/sh echo "Installation complete, running in host system" Anything obvious I am doing wrong? Or even the not-so-obvious would be welcome :-) Rgds, Claus
Claus Andersen
2015-May-29 17:17 UTC
[SOLVED][BUG??] Re: Unattended install using bsdinstall and ZFS
Hi! A quick re-cap: Want to do an unattended FreeBSD install using bsdinstall and ZFS. I now have a workaround and consider crying wol^H^H^Hbug. The following minimal install script works as expected for UFS: install-ufs.txt DISTRIBUTIONS="kernel.txz base.txz" RELEASE="10.1" PARTITIONS="da0" #!/bin/sh echo "Ready for post installation damage..." Invoke with: bsdinstall script install-ufs.txt Now switching to ZFS I would expect the following to work: install-zfs1.txt DISTRIBUTIONS="kernel.txz base.txz" RELEASE="10.1" ZFSBOOT_DISKS="da0 da1" ZFSBOOT_VDEV_TYPE="mirror" #!/bin/sh echo "Ready for post installation damage..." Invoke with: bsdinstall script install-zfs1.txt Failure: - ZFSBOOT_DISKS, ZFSBOOT_VDEV_TYPE not picked up - Asks for ZFS configuration interactively Miroslav Lachman hinted that from looking at the source I should set NONINTERACTIVE. This does not work. Hours later I have figure out the following which works(tm): install-zfs2.txt DISTRIBUTIONS="kernel.txz base.txz" RELEASE="10.1" export ZFSBOOT_DISKS="da0 da1" export ZFSBOOT_VDEV_TYPE="mirror" export nonInteractive="YES" #!/bin/sh echo "Ready for post installation damage..." Invoke with: bsdinstall script install-zfs2.txt This works as expected but it does not sit nice with me. But I am no guru so I would be very very happy if anyone can confirm if my findings are bogus or not? There is a huge number of indirect variables which really confuses me! It seems that either someone is putting in a lot of indirections but is not done yet - or vice versa. So "proper" usage is up in the air. Findings: - CAPITAL letters are used for "input" variables - CamelCase is used for "internal" variables. - NONINTERACTIVE should be set by default when using "bsdinstall script" - Setting NONINTERACTIVE manually is not picked up - Setting nonInteractive works but is bad practice and not intended by design - Doing export as part of the bsdinstall script is not what was intended by design Does these findings sound reasonable? If so - would it be fair to consider the current functionality a bug? Or am I too stupid to get the feature? I can file a PR and help out with test and documentation. But the current incarnation of bsdinstall is too convoluted for my low level of script-fu. Kind Regards, Claus Andersen
Miroslav Lachman
2015-Jun-04 19:57 UTC
[SOLVED][BUG??] Re: Unattended install using bsdinstall and ZFS
Claus Andersen wrote on 05/29/2015 19:17:> Hi! > > A quick re-cap: Want to do an unattended FreeBSD install using > bsdinstall and ZFS. I now have a workaround and consider crying > wol^H^H^Hbug. > > The following minimal install script works as expected for UFS: > > install-ufs.txt > DISTRIBUTIONS="kernel.txz base.txz" > RELEASE="10.1" > PARTITIONS="da0" > > #!/bin/sh > echo "Ready for post installation damage..." > > Invoke with: > bsdinstall script install-ufs.txt > > Now switching to ZFS I would expect the following to work: > > install-zfs1.txt > DISTRIBUTIONS="kernel.txz base.txz" > RELEASE="10.1" > ZFSBOOT_DISKS="da0 da1" > ZFSBOOT_VDEV_TYPE="mirror" > > #!/bin/sh > echo "Ready for post installation damage..." > > Invoke with: > bsdinstall script install-zfs1.txt > > Failure: > - ZFSBOOT_DISKS, ZFSBOOT_VDEV_TYPE not picked up > - Asks for ZFS configuration interactively > > Miroslav Lachman hinted that from looking at the source I should set > NONINTERACTIVE. This does not work. > > Hours later I have figure out the following which works(tm): > > install-zfs2.txt > DISTRIBUTIONS="kernel.txz base.txz" > RELEASE="10.1" > export ZFSBOOT_DISKS="da0 da1" > export ZFSBOOT_VDEV_TYPE="mirror" > export nonInteractive="YES" > > #!/bin/sh > echo "Ready for post installation damage..." > > Invoke with: > bsdinstall script install-zfs2.txt > > This works as expected but it does not sit nice with me. But I am no > guru so I would be very very happy if anyone can confirm if my findings > are bogus or not? There is a huge number of indirect variables which > really confuses me! It seems that either someone is putting in a lot of > indirections but is not done yet - or vice versa. So "proper" usage is > up in the air. > > Findings: > - CAPITAL letters are used for "input" variables > - CamelCase is used for "internal" variables. > - NONINTERACTIVE should be set by default when using "bsdinstall script" > - Setting NONINTERACTIVE manually is not picked up > - Setting nonInteractive works but is bad practice and not intended by > design > - Doing export as part of the bsdinstall script is not what was intended > by design > > Does these findings sound reasonable? If so - would it be fair to > consider the current functionality a bug? Or am I too stupid to get the > feature? > > I can file a PR and help out with test and documentation. But the > current incarnation of bsdinstall is too convoluted for my low level of > script-fu.I am out of free time so I cannot go deeper in this problem. But from what I see I can confirm your findings - it seems like a bug and it would be good if you can file a PR for it so it will not be lost. Miroslav Lachman