Bug 208601

Summary: sysutils/beadm: Cannot switch boot environment with the boot menu
Product: Ports & Packages Reporter: Kenneth <kenneth>
Component: Individual Port(s)Assignee: Allan Jude <allanjude>
Status: Closed FIXED    
Severity: Affects Many People CC: allanjude, allcoms, anubas, bdrewery, eborisch+FreeBSD, grahamperrin, jmc-freebsd2, moiseev, olgeni, vas
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Kenneth 2016-04-07 12:26:05 UTC
The system hang if the boot environment is switched with the boot menu (both UEFI and the old menu).
It only works to switch boot environment with beadm.

See https://forums.freebsd.org/threads/55755/
Comment 1 Allan Jude freebsd_committer freebsd_triage 2016-05-20 01:32:03 UTC
This happens if 'canmount' is set to 'yes' instead of the intended 'noauto' on any of the boot environments.

A fix to beadm has been submitted upstream.
Comment 2 Dan MacDonald 2016-07-26 23:43:35 UTC
Hi Allan

Was your patch to beadm accepted?

Could this fix make it in time for 11 and could you provide link to the patch please?

Thanks
Comment 3 Jimmy Olgeni freebsd_committer freebsd_triage 2016-09-03 08:21:34 UTC
Ping? I just got hit by this one :)
Comment 4 Allan Jude freebsd_committer freebsd_triage 2016-09-03 14:03:58 UTC
beadm is in ports, so its update is out-of-band from the 11.0-RELEASE cycle.

Upstream does not seem very responsive, the last direct commit by the author was a year ago, and the most recent activity was merging kmoore's pull request in February.

The fix everyone is waiting on has been an open pull request since May 4th.

I think we should either change the upstream git repo to someone more responsive (most active development seems to come from pcbsd/trueos), or apply the patch via the ports tree until it is accepted upstream.

What are your thoughts Bryan (you are the maintainer of the port)
Comment 5 Allan Jude freebsd_committer freebsd_triage 2016-09-09 15:01:01 UTC
The fix has been merged upstream, and should be available in ports shortly
Comment 6 Allan Jude freebsd_committer freebsd_triage 2016-09-09 15:01:31 UTC
*** Bug 211835 has been marked as a duplicate of this bug. ***
Comment 7 Victor Sudakov 2016-09-09 16:21:16 UTC
In the meanwhile, is there a way to fix the existing boot environments manually to make them bootable via the loader menu? 

Now that I look at them, all the BEs created with beadm have CANMOUNT=off except the current one which has CANMOUNT=on.
Comment 8 Allan Jude freebsd_committer freebsd_triage 2016-09-09 16:29:29 UTC
Set all of the BEs to canmount=noauto

and it should 'just work'
Comment 9 Victor Sudakov 2016-09-09 16:36:37 UTC
(In reply to Allan Jude from comment #8)

I tried, but when I manipulate with them with beadm, one of them (the current one?) becomes "on" inevitably.
Comment 10 Victor Sudakov 2016-09-09 17:04:26 UTC
(In reply to Allan Jude from comment #5)
Which one will be fixed, beadm or beadm-devel?
Comment 11 Allan Jude freebsd_committer freebsd_triage 2016-09-09 17:05:48 UTC
(In reply to vas from comment #9)
Yes, that is the bug that was fixed upstream this morning


If you use only the loader menu it will work.

You can change the default manually by doing:

zpool set bootfs=poolname/ROOT/bename poolname
Comment 12 Victor Sudakov 2016-09-10 05:06:32 UTC
(In reply to Allan Jude from comment #5)
Which one will be fixed, beadm or beadm-devel?(In reply to Allan Jude from comment #8)

Anyway, I can always use beadm from git master until the port is updated, right?
Comment 13 Allan Jude freebsd_committer freebsd_triage 2016-09-10 05:54:10 UTC
(In reply to vas from comment #12)
yes
Comment 14 Victor Sudakov 2016-09-10 12:39:44 UTC
(In reply to Allan Jude from comment #13)
Even the latest version from git is buggy: it leaves the original, first default BE with CANMOUNT=on, which prevents other BEs from booting properly. In the example below, the "kaban" BE was created with the newest beadm from git, and it would not boot from loader menu:

root@zfs2:~ # zfs list -o name,canmount,mountpoint
NAME                CANMOUNT  MOUNTPOINT
zroot                     on  /zroot
zroot/ROOT                on  none
zroot/ROOT/default        on  /
zroot/ROOT/kaban         off  /
zroot/tmp                 on  /tmp
zroot/usr                off  /usr
zroot/usr/home            on  /usr/home
zroot/usr/ports           on  /usr/ports
zroot/usr/src             on  /usr/src
zroot/var                off  /var
zroot/var/audit           on  /var/audit
zroot/var/crash           on  /var/crash
zroot/var/log             on  /var/log
zroot/var/mail            on  /var/mail
zroot/var/tmp             on  /var/tmp
root@zfs2:~ #
Comment 15 Victor Sudakov 2016-09-10 13:16:08 UTC
(In reply to vas from comment #14)
If you want to reproduce, do the following:

1. Install a fresh 10.3 system on zfs.
2. fetch beadm
3. beadm create foo
4. zfs list -o name,canmount,mountpoint | grep default
Comment 16 Victor Sudakov 2016-09-10 13:33:19 UTC
(In reply to vas from comment #15)
And when a BE is imported ("beadm import"), it also becomes CANMOUNT=on instead of noauto.

Something is terribly underdone.
Comment 17 Victor Sudakov 2016-09-11 07:56:12 UTC
root@vas:~ # ~sudakov/bin/beadm create September
Created successfully
root@vas:~ # ~sudakov/bin/beadm list
BE        Active Mountpoint  Space Created               Nickname
default   NR     /            6.8G 2016-08-13 22:50      default
install   -      -            3.6M 2016-08-13 23:01      install
nox11     -      -            1.3M 2016-08-14 00:58      nox11
September -      -          156.0K 2016-09-11 14:52      September
root@vas:~ # zfs list -o name,canmount,mountpoint | grep ROO
zroot/ROOT                  on  none
zroot/ROOT/September       off  /
zroot/ROOT/default          on  /
zroot/ROOT/install         off  /
zroot/ROOT/nox11           off  /
root@vas:~ # 

Shouldn't 'September' have been created with canmount=noauto? 

MD5 (/home/sudakov/bin/beadm) = 3f0be545978bae0202d2d6952516664a
Comment 18 Victor Sudakov 2016-09-15 05:19:58 UTC
Ping!
Comment 19 Allan Jude freebsd_committer freebsd_triage 2016-09-15 06:03:01 UTC
There are still issues, Bryan Drewery is working on it.

It looks like an rc script will need to be brought into the package to manage boot environments with children.

Bryan is also looking at porting the IllumOS beadm, rather than the hodgepodge shell script we have now.

It is not clear when this will be completely resolved.
Comment 20 Graham Perrin freebsd_committer freebsd_triage 2017-03-07 01:12:00 UTC
Is https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214430 a duplicate?

> sysutils/beadm: please update to latest to support loader menu (via 'noauto')
Comment 21 Victor Sudakov 2017-03-07 01:29:13 UTC
(In reply to Graham Perrin from comment #20)
I think it is.
Comment 22 Dan MacDonald 2017-07-31 23:29:22 UTC
Is there any update on this?

Allan said B.Drewery is working on fixing this but his beadm GH repo doesn't seem to have been updated since 2015:

https://github.com/bdrewery/beadm

Is that not the one you're referring to Allan?
Comment 23 Bryan Drewery freebsd_committer freebsd_triage 2017-08-01 00:34:32 UTC
(In reply to Dan MacDonald from comment #22)
> Is there any update on this?
> 
> Allan said B.Drewery is working on fixing this but his beadm GH repo doesn't
> seem to have been updated since 2015:
> 
> https://github.com/bdrewery/beadm
> 
> Is that not the one you're referring to Allan?

The fix requires an rc script that may go into the base system or the port.
I have not pushed it out to git.
Comment 24 eborisch+FreeBSD 2017-08-01 01:24:53 UTC
With rc.d/zfsbe in 11.1, can something be done to make this work out of the box? I patch my beadm installs to only set canmount=noauto, and am a zery happy camper.
Comment 25 Bryan Drewery freebsd_committer freebsd_triage 2017-08-01 01:27:11 UTC
(In reply to eborisch+FreeBSD from comment #24)
> With rc.d/zfsbe in 11.1, can something be done to make this work out of the
> box? I patch my beadm installs to only set canmount=noauto, and am a zery
> happy camper.

Yeah, beadm could check if that script exists and change the canmount behavior
it applies.
Comment 26 Bryan Drewery freebsd_committer freebsd_triage 2018-01-18 20:31:50 UTC
*** Bug 214430 has been marked as a duplicate of this bug. ***
Comment 27 Bryan Drewery freebsd_committer freebsd_triage 2018-01-18 20:33:15 UTC
(In reply to Bryan Drewery from comment #25)
> (In reply to eborisch+FreeBSD from comment #24)
> > With rc.d/zfsbe in 11.1, can something be done to make this work out of the
> > box? I patch my beadm installs to only set canmount=noauto, and am a zery
> > happy camper.
> 
> Yeah, beadm could check if that script exists and change the canmount
> behavior
> it applies.

Similar handling will be needed for `beadm mount` to properly mount the
child datasets as well.
Comment 28 eborisch+FreeBSD 2018-01-18 20:51:18 UTC
(In reply to Bryan Drewery from comment #27)

It appears beadm mount handles mounting the child datasets fine. (At least for me; perhaps I don't have quite the same setup?) And (as mentioned above) rc.d/zfsbe in 11.1 handles it on boot.

system/ROOT/11.1-p5            2.67M  13.2G  7.20G  /
system/ROOT/11.1-p5/usr         764K  13.2G   132K  none
system/ROOT/11.1-p5/usr/local   764K  13.2G  4.79G  /usr/local

# beadm mount 11.1-p5 /tmp/newbe
Mounted successfully on '/tmp/newbe'

system/ROOT/11.1-p5 on /tmp/newbe (zfs, local, noatime, nfsv4acls)
system/ROOT/11.1-p5/usr/local on /tmp/newbe/usr/local (zfs, local, noatime, nfsv4acls)

Not to mention that 'noauto' will also help avoid users doing backups (send/recv w/o -u) getting a nasty surprise.
Comment 29 commit-hook freebsd_committer freebsd_triage 2018-01-18 21:12:43 UTC
A commit references this bug:

Author: bdrewery
Date: Thu Jan 18 21:12:30 UTC 2018
New revision: 459380
URL: https://svnweb.freebsd.org/changeset/ports/459380

Log:
  - Properly support selecting BE from boot menu.
    This is only supported for releases that have /etc/rc.d/zfsbe, which is
    10.4, 11.1, and newer.

  PR:		208601
  Reported by:	many
  Reviewed by:	allanjude

Changes:
  head/sysutils/beadm/Makefile
  head/sysutils/beadm/files/patch-beadm
  head/sysutils/beadm/files/patch-beadm.1
Comment 30 Bryan Drewery freebsd_committer freebsd_triage 2018-01-18 21:13:18 UTC
Sorry for the long delay on this! Having /etc/rc.d/zfsbe in a majority of supported
releases made this simpler.
Comment 31 Victor Sudakov 2018-01-21 09:29:46 UTC
(In reply to commit-hook from comment #29)
Will sysutils/beadm-devel be fixed too?
Comment 32 Bryan Drewery freebsd_committer freebsd_triage 2018-01-22 21:12:09 UTC
(In reply to vas from comment #31)
> (In reply to commit-hook from comment #29)
> Will sysutils/beadm-devel be fixed too?

Thanks for the reminder, done.
Comment 33 commit-hook freebsd_committer freebsd_triage 2018-01-22 21:12:24 UTC
A commit references this bug:

Author: bdrewery
Date: Mon Jan 22 21:11:59 UTC 2018
New revision: 459701
URL: https://svnweb.freebsd.org/changeset/ports/459701

Log:
  Update to latest e55f535b589fb2df4e65e51482e29337b564b756 which fixes
  BE boot-time selection.

  PR:		208601

Changes:
  head/sysutils/beadm-devel/Makefile
  head/sysutils/beadm-devel/distinfo