Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unattended install using bsdinstall and ZFS

536 views
Skip to first unread message

Claus Andersen

unread,
May 19, 2015, 5:06:40 AM5/19/15
to freebsd...@freebsd.org
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!

Kind Regards,
Claus Andersen
_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stabl...@freebsd.org"

Miroslav Lachman

unread,
May 19, 2015, 6:53:16 AM5/19/15
to Claus Andersen, freebsd...@freebsd.org
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

Claus Andersen

unread,
May 19, 2015, 8:34:47 AM5/19/15
to Miroslav Lachman, freebsd...@freebsd.org
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 NONINTERACTIVE

Thanks! 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

unread,
May 29, 2015, 1:18:00 PM5/29/15
to freebsd...@freebsd.org
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

unread,
Jun 4, 2015, 4:03:25 PM6/4/15
to Claus Andersen, freebsd...@freebsd.org
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

Patrick M. Hausen

unread,
Jul 29, 2015, 3:54:47 AM7/29/15
to Claus Andersen, freebsd...@freebsd.org
Hi, Claus,

> Am 29.05.2015 um 19:17 schrieb Claus Andersen <cl...@wheel.dk>:
>
> 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:
> [...]
> 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..."

Thanks for your detailled report. I can confirm your findings and I was able to do an unattended install using these settings:

DISTRIBUTIONS="base.txz doc.txz games.txz kernel.txz lib32.txz"
INTERFACES="em0"
export ZFSBOOT_DISKS="da0 da1"
export ZFSBOOT_VDEV_TYPE="mirror"
export ZFSBOOT_FORCE_4K_SECTORS="1"
export ZFSBOOT_SWAP_SIZE="8g"
export ZFSBOOT_SWAP_MIRROR="1"
export ZFSBOOT_POOL_CREATE_OPTIONS="-O compress=lz4 -O checksum=fletcher4"
export nonInteractive="YES"

Yet, there are still 2 things that prevent a truly unattended installation. First, at least for me,
the installer alway displays a dialog with debug messages which needs to be explicitly
confirmed at the end of the installation. This is not the case if I use UFS. With UFS it just
reboots into the freshly installed system.

I could work around that one by explicitly calling "reboot" at the end of the shell script
part of installerconfig.

Second, if you do remote installation via IPMI and serial console over IP, the standard install
environment copied from CD calls this code in /etc/rc.local:

[...]
else
# Serial or other console
echo
echo "Welcome to FreeBSD!"
echo
echo "Please choose the appropriate terminal type for your system."
echo "Common console types are:"
echo " ansi Standard ANSI terminal"
echo " vt100 VT100 or compatible terminal"
echo " xterm xterm terminal emulator (or compatible)"
echo " cons25w cons25w terminal"
echo
echo -n "Console type [vt100]: "
read TERM
TERM=${TERM:-vt100}
fi

IMHO hardwiring this is not a good idea. Can be solved by simply commenting out the unwanted
parts, but this should be configurable in installerconfig. Currently it quite defeats the purpose of
*unattended* installations. At least I expect "power on, get some coffee, login via ssh into newly
installed system" ;-)

Kind regards
Patrick M. Hausen
Leiter Netzwerke und Sicherheit
--
punkt.de GmbH * Kaiserallee 13a * 76133 Karlsruhe
Tel. 0721 9109 0 * Fax 0721 9109 100
in...@punkt.de http://www.punkt.de
Gf: Jürgen Egeling AG Mannheim 108285
0 new messages