Bug 216985 - shells/bash: following pkg-message wrecks the system boot
Summary: shells/bash: following pkg-message wrecks the system boot
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Emanuel Haupt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-10 23:10 UTC by John Smith
Modified: 2017-02-11 13:22 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (ehaupt)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Smith 2017-02-10 23:10:56 UTC
1.
pkg info -D bash
bash-4.4.12:
Always:
======================================================================

bash requires fdescfs(5) mounted on /dev/fd

If you have not done it yet, please do the following:

	mount -t fdescfs fdesc /dev/fd

To make it permanent, you need the following lines in /etc/fstab:

	fdesc	/dev/fd		fdescfs		rw	0	0

======================================================================


2. adding the suggested line to the '/etc/fstab' causes the system to fail to boot properly, it boots into a single user mode instead.
Comment 1 John Smith 2017-02-10 23:23:13 UTC
Turns out there's 'fdescfs' kernel module, so one needs to add

fdescfs_load="YES"

to the '/boot/loader.conf' in order to resolve the issue.
This is important.
This should be mentioned in the pkg-message as well.
Comment 2 Tobias Kortkamp freebsd_committer 2017-02-11 04:23:45 UTC
I've raised this before for OpenJDK (which has a similar pkg-message) in bug #204977.

Instead of adding fdescfs_load="YES" to /boot/loader.conf you can also add 'late' to the fstab entry:

	fdesc	/dev/fd		fdescfs		rw,late	0	0

By mounting it later in the boot the system can autoload the kernel module.  Autoloading will fail if /boot isn't mounted yet.
Comment 3 John Smith 2017-02-11 09:43:59 UTC
(In reply to Tobias Kortkamp from comment #2)
I know I can. This bug is particularly about the pkg-message which currently advises the user to break the booting.
I don't know why you closed your bug, I also had to file Bug 216983 which covers similar issue in another port.
Comment 4 Emanuel Haupt freebsd_committer 2017-02-11 10:24:38 UTC
I can not reproduce this in the following reference VM's:

FreeBSD 10.3-RELEASE, amd64
FreeBSD 10.3-RELEASE, i386

FreeBSD 11.0-RELEASE, amd64
FreeBSD 11.0-RELEASE, i386

Adding the suggested fstab line from pkg-message will in all cases autoload the fdescfs kernel module:

$ kldstat | grep fdesc
 2    1 0xc63db000 4000     fdescfs.ko

The VM's are all vanilla with only bash installed and without any other modifications.

Please add more details.
Comment 5 John Smith 2017-02-11 10:31:23 UTC
(In reply to Emanuel Haupt from comment #4)
11.0-RELEASE-p1, amd64, physical machine.
just adding the line suggested from pkg-message into '/etc/fstab' file doesn't autoload the mentioned kernel module, so upon a reboot the system aborts BOOT and boots into a single user mode.
If I manually tell the system to load 'fdescfs' module via '/boot/loader.conf' - then the boot goes fine.
Another solution is to add 'late' option to the fdescfs mount, then everything boots fine too.
Comment 6 Emanuel Haupt freebsd_committer 2017-02-11 10:41:04 UTC
I'm also using the exact line from pkg-message on my physical server without being able to reproduce the error.

Hanging filesystem mounts during boot time often indicate a corrupted entry. Could it be in your case that an illegal character was inserted during copy pasting (ie. some UTF-8 character)?

Test with:

$ file /etc/fstab
/etc/fstab: ASCII text

Can you show the full contents of your fstab file which is crashing during boot?
Comment 7 Tobias Kortkamp freebsd_committer 2017-02-11 10:42:55 UTC
(In reply to Emanuel Haupt from comment #4)
This happens on systems that have a separate boot partition e.g. systems with an encrypted root partition.

It's impossible for modules to be autoloaded when /boot/kernel isn't available yet.

The FreeBSD 10.3-RELEASE installer will create such a system when you select ZFS and enable full-disk encryption.
Comment 8 John Smith 2017-02-11 11:08:59 UTC
Tobias is probably right.
I have everything on encrypted ZFS and because I use MBR - I have 2 zpools: bootpool and zroot.

'file /etc/fstab' also tells that it's ASCII text, and no, it's not corrupted. And other lines are fine (except the same exact issue with linux_base-c6's pkg-message which also advises to add mounts for linprocfs and tmpfs).
Comment 9 Emanuel Haupt freebsd_committer 2017-02-11 11:46:40 UTC
Now I was able to reproduce it (FreeBSD installer, ZFS, full-disk encryption).

I think it makes sense to advise using the late mount option in all cases as the most efficient way as it will work in all cases.

What do you think about the following pkg-message:

======================================================================

bash requires fdescfs(5) mounted on /dev/fd

If you have not done it yet, please do the following:

        mount -t fdescfs fdesc /dev/fd

To make it permanent, you need the following lines in /etc/fstab:

        fdesc   /dev/fd         fdescfs         rw,late 0       0

The late mount option is required for systems with a seperate boot
partition  (e.g. systems with an encrypted root partition) where it
is impossible for the fdescfs module to be autoloaded when
/boot/kernel isn't available yet.

======================================================================
Comment 10 John Smith 2017-02-11 11:54:55 UTC
(In reply to Emanuel Haupt from comment #9)
I am okay with that.
However, it would be shorter and simpler to just add ',late' mount option to the currently advised fstab entry, because I doubt that it's going to make any harm or difference even for people without separate boot partition.
Comment 11 John Smith 2017-02-11 11:57:06 UTC
Also, I'd advise you to change 'fdesc' mount point name to 'fdescfs' to simplify things: this way 'mount fdescfs' will work just as fine as 'umount fdescfs'.
The less things to remember - the better it is.
Comment 12 Emanuel Haupt freebsd_committer 2017-02-11 13:00:03 UTC
Good call. That looks easier to remember.
Comment 13 commit-hook freebsd_committer 2017-02-11 13:12:47 UTC
A commit references this bug:

Author: ehaupt
Date: Sat Feb 11 13:11:58 UTC 2017
New revision: 433857
URL: https://svnweb.freebsd.org/changeset/ports/433857

Log:
  The late mount option is required for systems with a seperate boot partition
  (e.g. systems with an encrypted root partition) where it is impossible for the
  fdescfs module to be autoloaded when /boot/kernel isn't available yet. Change
  pkg-message accordingly.

  Also change 'fdesc' mount point name to 'fdescfs' to simplify things: this way
  'mount fdescfs' will work just as fine as 'umount fdescfs'. The less things to
  remember - the better it is.

  PR:		216985
  Submitted by:	John Smith <godevilove@ya.ru>

Changes:
  head/shells/bash/pkg-message
Comment 14 commit-hook freebsd_committer 2017-02-11 13:13:50 UTC
A commit references this bug:

Author: ehaupt
Date: Sat Feb 11 13:13:37 UTC 2017
New revision: 433859
URL: https://svnweb.freebsd.org/changeset/ports/433859

Log:
  MFH: r433857

  The late mount option is required for systems with a seperate boot partition
  (e.g. systems with an encrypted root partition) where it is impossible for the
  fdescfs module to be autoloaded when /boot/kernel isn't available yet. Change
  pkg-message accordingly.

  Also change 'fdesc' mount point name to 'fdescfs' to simplify things: this way
  'mount fdescfs' will work just as fine as 'umount fdescfs'. The less things to
  remember - the better it is.

  PR:		216985
  Submitted by:	John Smith <godevilove@ya.ru>
  Approved by:	ports-secteam (blanket)

Changes:
_U  branches/2017Q1/
  branches/2017Q1/shells/bash/pkg-message