Bug 210865 - bsdinstall: install faill with ZFSBOOT_DATASETS=da0
Summary: bsdinstall: install faill with ZFSBOOT_DATASETS=da0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-RC1
Hardware: Any Any
: --- Affects Only Me
Assignee: Allan Jude
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-07-06 04:20 UTC by h-fujishima
Modified: 2020-07-11 18:30 UTC (History)
4 users (show)

See Also:


Attachments
dmesg -a (19.16 KB, image/png)
2016-07-06 14:09 UTC, h-fujishima
no flags Details
new patch (338 bytes, patch)
2016-07-06 14:12 UTC, h-fujishima
no flags Details | Diff
umount (42.15 KB, image/jpeg)
2016-07-22 09:26 UTC, h-fujishima
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description h-fujishima 2016-07-06 04:20:59 UTC
When the preamble contain the variable ZFSBOOT_DATASETS install process fail.
Because $TMP_FSTAB of bsdinstall/umount is empty.

```
--- FreeBSD-10.3-RELEASE-amd64-disc1/usr/libexec/bsdinstall/umount.orig 2016-03-25 11:14:43.000000000 +0900
+++ FreeBSD-10.3-RELEASE-amd64-disc1/usr/libexec/bsdinstall/umount      2016-07-06 12:39:21.810951339 +0900
@@ -39,4 +39,4 @@
 }' > $TMP_FSTAB

 umount $BSDINSTALL_CHROOT/dev 2>/dev/null
-umount -F $TMP_FSTAB -a 2>/dev/null
+test -s $TMP_FSTAB && umount -F $TMP_FSTAB -a 2>/dev/null
```

FreeBSD-10.3-RELEASE-amd64-disc1/usr/libexec/bsdinstall/script
```
############################################################ FUNCTIONS

error()
{
        [ -f "$PATH_FSTAB" ] && bsdinstall umount

        local file
        f_getvar "$VAR_DEBUG_FILE#+" file
        if [ "$file" ]; then
                f_dialog_title "$msg_installation_error"
                f_dialog_textbox "$file"
                # No need to restore title, pining for the fjords
        fi

        exit 1
}

############################################################ MAIN

set -e
trap error EXIT

[...]

bsdinstall entropy
bsdinstall umount <= fail!!

f_dprintf "Installation Completed at %s" "$( date )"
```
Comment 1 h-fujishima 2016-07-06 14:09:17 UTC
Created attachment 172171 [details]
dmesg -a
Comment 2 h-fujishima 2016-07-06 14:12:24 UTC
Created attachment 172172 [details]
new patch

the last patch does not fix problem.
the correct one is here.
Comment 3 Allan Jude freebsd_committer 2016-07-16 18:10:14 UTC
I am very unclear on what caused the error.

Setting ZFSBOOT_DATASETS to 'da0' is invalid, it is supposed to be a list of datasets to create, and search should start with a /, as it is prefixed with the pool name. You also need to create some dataset with a mountpoint of /.

I also do not see how setting this variable affects TMP_FSTAB, with ZFS, it is always blank except for swap.

Can you provide a fuller reproduction case?
Comment 4 h-fujishima 2016-07-22 09:26:40 UTC
Created attachment 172829 [details]
umount
Comment 5 h-fujishima 2016-07-22 09:31:09 UTC
Sorry ZFSBOOT_DATASETS is typo...

Here is /etc/installerconfig:

DISTRIBUTIONS="kernel.txz base.txz src.txz"
export ZFSBOOT_DISKS=nvd0
export ZFSBOOT_DISKS=da0
export ZFSBOOT_SWAP_SIZE=64g
export ZFSBOOT_DATASETS="
/ROOT           mountpoint=none
/ROOT/default   mountpoint=/
/tmp            mountpoint=/tmp,exec=on,setuid=off
/usr            mountpoint=/usr,canmount=off
/home           mountpoint=/home
/home/admin
/usr/ports      setuid=off
/usr/src
/usr/local
/var            mountpoint=/var,canmount=off
/var/audit      exec=off,setuid=off
/var/crash      exec=off,setuid=off
/var/log        exec=off,setuid=off
/var/db         canmount=off
/var/db/pkg
/var/mail       atime=on
/var/tmp        setuid=off
"
export nonInteractive=1

I uploaded the detail error message screen shot file.
Comment 6 h-fujishima 2016-08-17 08:34:30 UTC
11.0-RC1 has same problem.
Comment 7 Tim Lukasiewicz 2016-10-06 05:07:40 UTC
I think the issue is that on a clean install with root on ZFS, the only entry in the $PATH_FSTAB file is a swap partition, which doesn't match the RegEx on line 32 and leaves $TMP_FSTAB empty.

I created a workaround/potential patch to ensure that $TMP_FSTAB was non-zero length before trying to feed it into umount and was able to install successfully afterwards.  

--- /usr/libexec/bsdinstall/umount      2016-08-04 21:28:50.000000000 -0500
+++ ./umount    2016-10-05 23:33:25.750217000 -0500
@@ -39,4 +39,6 @@
 }' > $TMP_FSTAB

 umount $BSDINSTALL_CHROOT/dev 2>/dev/null
+if [ -s $TMP_FSTAB ]; then
 umount -F $TMP_FSTAB -a 2>/dev/null
+fi
Comment 8 Christian Ullrich 2017-02-11 21:40:16 UTC
I just spent several hours coming to the same conclusion as the previous comment, and then found this bug. Any change of it getting some attention?

It is still a problem in 11-STABLE, and I cannot see how it could not also affect -CURRENT.
Comment 9 Sean Eric Fagan freebsd_committer 2019-04-25 21:04:27 UTC
The change seems fine to me, but I'm unclear under what circumstances it would happen.  (I have done multiple installs with ZFS root, and not run into this problem.)
Comment 10 commit-hook freebsd_committer 2020-07-11 17:07:39 UTC
A commit references this bug:

Author: allanjude
Date: Sat Jul 11 17:06:48 UTC 2020
New revision: 363101
URL: https://svnweb.freebsd.org/changeset/base/363101

Log:
  bsdinstall: don't fail if fstab is empty

  PR:		210865
  Submitted by:	Tim Lukasiewicz <eclipzetech08@gmail.com>, h-fujishima@sakura.ad.jp (original version)
  Reported by:	h-fujishima@sakura.ad.jp
  Reviewed by:	sef
  MFC after:	2 weeks
  Sponsored by:	Klara Inc.
  Event:		July 2020 Bugathon

Changes:
  head/usr.sbin/bsdinstall/scripts/umount