Bug 233657

Summary: bectl siliently fails on i386
Product: Base System Reporter: Philip Homburg <pch-freebsd-bugs-1>
Component: binAssignee: Kyle Evans <kevans>
Status: New ---    
Severity: Affects Only Me CC: grahamperrin, kevans, rob.fx907
Priority: ---    
Version: 12.0-RELEASE   
Hardware: i386   
OS: Any   

Description Philip Homburg 2018-11-30 09:43:07 UTC
bectl on i386 with root on zfs silently fails.

bectl list gives no output

bectl create gives no output

Same thing happens when root is ufs.
Comment 1 Rob 2018-12-19 20:49:41 UTC
(In reply to Philip Homburg from comment #0)

I wasn't able to reproduce this problem on a VM.

root@test:~ # uname -a
FreeBSD test 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  i386

root@test:~ # bectl create bootenv
/* no output */

root@test:~ # bectl list
BE      Active Mountpoint Space Created
default NR     /          423M  2018-12-19 11:37
bootenv -      -          8K    2018-12-19 11:46

root@test:~ # gpart show
=>      40  33554352  vtbd0  GPT  (16G)
        40      1024      1  freebsd-boot  (512K)
      1064       984         - free -  (492K)
      2048   4194304      2  freebsd-swap  (2.0G)
   4196352  29356032      3  freebsd-zfs  (14G)
  33552384      2008         - free -  (1.0M)
Comment 2 Philip Homburg 2018-12-20 00:40:31 UTC
My laptop boots from BIOS and has MBR. Could that make a difference?
Comment 3 Rob 2018-12-23 22:19:53 UTC
(In reply to Philip Homburg from comment #2)

I don't know how it would.

Given that no error messages are produced, my hunch is bectl is failing to initialize

'bectl' uses libbe(3) to initialize a boot environment to work from. The following is a description about 'libbe_init()' from the libbe(3) man page:

     The libbe_init() function takes an optional BE root and initializes
     libbe, returning a libbe_handle_t * on success, or NULL on error.  If a
     BE root is supplied, libbe will only operate out of that pool and BE
     root.  An error may occur if:

     /boot and / are not on the same filesystem and device,
     libzfs fails to initialize,
     The system has not been properly booted with a ZFS boot environment,
     libbe fails to open the zpool the active boot environment resides on, or
     libbe fails to locate the boot environment that is currently mounted.

That may help you trouble-shoot the cause. 

Another thing to try is, pass the root boot environment (i.e. zroot/ROOT) to bectl explicitly. This is undocumented but, you can pass the '-r' flag before any of the 'bectl' commands (create, list, destroy, etc.). Here's an example:

To create boot environment named 'bootenv' under the boot root zroot/ROOT
# bectl -r zroot/ROOT create bootenv

To list a boot environment under zroot/ROOT
# bectl -r zroot/ROOT list

I'm curious what you come up with.
Comment 4 Graham Perrin 2019-01-04 06:10:15 UTC
(In reply to Philip Homburg from comment #0)

> bectl list gives no output

I may be mistaken but I vaguely recall that for me there was no output, no listing, prior to my first use of a 'bectl create …' command. 

At the moment I don't have a clean installation of FreeBSD with which to test. 


Comparing for a moment with beadm, 

[grahamperrin@ghostbsd-virtual] ~% date ; uname -v
Fri Jan  4 05:58:07 GMT 2019
FreeBSD 12.0-CURRENT #0 7ad4fada6(HEAD): Thu Aug  2 11:37:15 EDT 2018     root@hydra:/usr/obj/root/jenkins/workspace/TrueOS_-_Stable_-_Complete/TrueOS_Stable/amd64.amd64/sys/GENERIC 
[grahamperrin@ghostbsd-virtual] ~% beadm
  beadm activate <beName>
  beadm create [-e nonActiveBe | -e beName@snapshot] <beName>
  beadm create <beName@snapshot>
  beadm destroy [-F] <beName | beName@snapshot>
  beadm list [-a] [-s] [-D] [-H]
  beadm rename <origBeName> <newBeName>
  beadm mount <beName> [mountpoint]
  beadm { umount | unmount } [-f] <beName>
[grahamperrin@ghostbsd-virtual] ~% bectl
bectl: Command not found.
[grahamperrin@ghostbsd-virtual] ~% sudo pkg install bectl
Updating GhostBSD-base repository catalogue...
GhostBSD-base repository is up to date.
Updating GhostBSD-ports repository catalogue...
GhostBSD-ports repository is up to date.
All repositories are up to date.
pkg: No packages available to install matching 'bectl' have been found in the repositories
[grahamperrin@ghostbsd-virtual] ~% beadm list
BE      Active Mountpoint  Space Created
initial NR     /            3.8G 2019-01-04 05:22
[grahamperrin@ghostbsd-virtual] ~% beadm list -s
BE/Dataset/Snapshot             Active Mountpoint  Space Created

  ghostbsd-virtual/ROOT/initial NR     /            3.8G 2019-01-04 05:22
[grahamperrin@ghostbsd-virtual] ~%
Comment 5 Kyle Evans freebsd_committer 2019-03-19 18:53:01 UTC
(In reply to Philip Homburg from comment #0)

If you can still reproduce this, can you post `zfs list` output, please?

Also, take now that I've become aware of this report.
Comment 6 Philip Homburg 2019-03-23 12:06:50 UTC
bootpool             227M  1.53G   226M  /bootpool
zroot               4.33G  9.96G    88K  /zroot
zroot/ROOT          2.98G  9.96G    88K  none
zroot/ROOT/default  2.98G  9.96G  2.98G  /
zroot/tmp             96K  9.96G    96K  /tmp
zroot/usr           1.34G  9.96G    88K  /usr
zroot/usr/home       172K  9.96G   172K  /usr/home
zroot/usr/ports      686M  9.96G   686M  /usr/ports
zroot/usr/src        688M  9.96G   688M  /usr/src
zroot/var            740K  9.96G    88K  /var
zroot/var/audit       88K  9.96G    88K  /var/audit
zroot/var/crash       88K  9.96G    88K  /var/crash
zroot/var/log        280K  9.96G   280K  /var/log
zroot/var/mail       104K  9.96G   104K  /var/mail
zroot/var/tmp         92K  9.96G    92K  /var/tmp
Comment 7 Rob 2019-03-23 19:40:15 UTC
(In reply to Philip Homburg from comment #6)

What's the output from 'bectl -r zroot/ROOT list'?
Comment 8 Philip Homburg 2019-03-24 14:59:09 UTC
Hmm. When I reported the problem the system was running 12.0-RC1 and freebsd-update failed to upgrade the system. I create a report for that as well and then mostly forgot about it.

The command 'bectl -r zroot/ROOT list' doesn't seem to work on 12.0-RC1 so I wanted to upgrade to 12.0-p3 first.

On a hunch I created a /boot symlink and tried freebsd-update again. That worked.

But now, bectl works as well.

I'll try a re-install to see if it was just a bug in 12.0-RC1.