[Bug 271384] zpool not imported if zfs isn't enabled in loader.conf

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 13 May 2023 02:53:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271384

            Bug ID: 271384
           Summary: zpool not imported if zfs isn't enabled in loader.conf
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: phryk-ports@wzff.de

Without `zfs_load="YES"` and `zpool_cache_*` (presumably both, but haven't
tested in isolation) in `loader.conf`, zpools don't get imported during
init – even if `/etc/rc.conf` contains `zfs_enable="YES"`.

This means that on setups with zfs-independent boot, at least automatic
mounting doesn't work – but probably also that mounting zfs datasets
via fstab becomes impossible.

There is an `/etc/rc.d/zpool` that does the import, but it only seems to be
invoked by `/etc/rc.d/zfskeys` which seems to be for a completely different
use-case. I fixed this on my system by adding this to `/etc/rc.d/zfs`:

```
start_precmd="zfs_prestart"

zfs_prestart(){
    if checkyesno zpool_enable; then
        /etc/rc.d/zpool start
    fi
}
```

And then `zpool_enable="YES"` to my rc.conf.

There might be a more elegant way of checking whether the `zpool start`
should be invoked than introducing a new variable to `rc.conf` and there
probably should also be a poststop command to do `zpool stop` but I'm
migrating away from zfs, it's already over 10 hours after I wanted to be
done with the initial migration and I'm definitely not pouring more time
into this – just wanted to hand this over on my way out the door.

-- 
You are receiving this mail because:
You are the assignee for the bug.