Page MenuHomeFreeBSD

Make libzfs not autoload the ZFS module
Needs ReviewPublic

Authored by allanjude on Jun 19 2026, 3:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 8, 11:41 PM
Unknown Object (File)
Fri, Jul 3, 12:59 PM
Unknown Object (File)
Wed, Jul 1, 6:50 PM
Unknown Object (File)
Wed, Jul 1, 6:39 PM
Unknown Object (File)
Mon, Jun 29, 5:47 PM
Unknown Object (File)
Mon, Jun 29, 5:43 PM
Unknown Object (File)
Fri, Jun 26, 1:57 PM
Unknown Object (File)
Fri, Jun 26, 1:11 AM

Details

Reviewers
markj
gordon
Summary

Only load the module if the env var ZFS_AUTOLOAD_MODULE is set to YES

This prevents zpool status loading the ZFS module as a side effect.

PR: 295485
Reported by: Dan Mahoney
Event: BSDcan 2026
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73990
Build 70873: arc lint + arc unit

Event Timeline

Do we need to have rc.d/zfs kldload zfs as-needed in case someone's implicitly relying on this and running ZFS strictly for data pools rather than root? I think that would make this a non-event for 98%+ of our users if it wasn't already.

It was determined that zpool status and zfs list are not the commands used in the original context. Instead:

zpool upgrade -v
and:
zfs upgrade -v

An upstream change has been proposed:

https://github.com/openzfs/zfs/pull/18694/changes/3c971d9b219ac135767802c5c014fdd687dacf5b

Because, unlike FreeBSD, the Linux zpool upgrade -v does depends on some kernel module results ( /sys/module/zfs/features.pool ), that part of the proposed change is FreeBSD OS specific and Linux would still load its kernel module.

Linux does not use kernel module results for zfs upgrade -v and, so, that part is more general.

It was determined that zpool status and zfs list are not the commands used in the original context. Instead:

zpool upgrade -v
and:
zfs upgrade -v

An upstream change has been proposed:

https://github.com/openzfs/zfs/pull/18694/changes/3c971d9b219ac135767802c5c014fdd687dacf5b

Because, unlike FreeBSD, the Linux zpool upgrade -v does depends on some kernel module results ( /sys/module/zfs/features.pool ), that part of the proposed change is FreeBSD OS specific and Linux would still load its kernel module.

Linux does not use kernel module results for zfs upgrade -v and, so, that part is more general.

Either way, running zpool status should ALSO not load zfs.ko automatically.

Do we need to have rc.d/zfs kldload zfs as-needed in case someone's implicitly relying on this and running ZFS strictly for data pools rather than root? I think that would make this a non-event for 98%+ of our users if it wasn't already.

Need to do more tests to confirm, but it looks like the required_modules="zfs" in rc.d/zpool that it should get taken care of that way

Need to make sure this doesn't cause problems in bsdinstall, I think the only other place where we might need to explicitly load the module.