How to add zfs support to FreeBSD

Jeremy Chadwick jdc at
Tue Feb 19 17:37:23 UTC 2013

On Tue, Feb 19, 2013 at 09:09:07AM +0000, Teske, Devin wrote:
> 4. lsvfs output?
> -- 
> Devin
> ________________________________________
> From: owner-freebsd-questions at [owner-freebsd-questions at] on behalf of Jeremy Chadwick [jdc at]
> Sent: Tuesday, February 19, 2013 12:16 AM
> To: freebsd-questions at
> Cc: fbsd8 at; freebsd at
> Subject: Re: How to add zfs support to FreeBSD
> Regarding all the recommendations on "how to determine if ZFS is
> available on the system":
> Do not run commands like /sbin/zfs or /sbin/zpool right off the bat.
> This will result in the underlying kld bits dynamically loading zfs.ko
> and opensolaris.ko on the fly -- even if there aren't any ZFS
> filesystems used -- which takes up kernel memory.  This also generates
> crap on the console, and I can assure you an SA running some script is
> not expecting this.  (An example is a system I admin which does not use
> ZFS, but I often forget that fact and type "zpool status" as root by
> accident, which loads ZFS, etc. -- I ended up using WITHOUT_CDDL on that
> system just to keep that from happening ;-) ).
> The OP needs to define what he means by "enabled on the host".  This
> could mean:
> a) The host actually has ZFS compiled or not (e.g. WITHOUT_ZFS and/or
> WITHOUT_CDDL and/or WITHOUT_CTF are not defined in src.conf),
> b) The host is capable of using ZFS (e.g. kernel modules are built and
> installed but are not loaded),
> c) The host has the kernel modules loaded but are not actually in use
> (e.g. zfs_enable="yes" in rc.conf but no ZFS filesystems defined),
> d) The host has the kernel modules loaded and actively has ZFS
> filesystems in use.
> Recommendations (meaning you get to use a combination of these to create
> proper logic depending on what you want -- please keep in mind what I
> just said about using /sbin/zpool and so on however):
> 1) Check for the existence of /sbin/zfs (e.g. if [ -x ... ]).  If it
> exists, the system was built without WITHOUT_{ZFS,CDDL,CTF} set.  (Sorry
> for the double negative).
> 2) Use "sysctl -n vfs.zfs.version.zpl" and check exit code.  If 1, the
> kernel modules are not loaded, else they are.
> 3) Run "/sbin/zpool list -H" and see if there's any output.  If there
> is, there are pools defined, which means in some way or another ZFS is
> being used by the system.  (Note that I recommend using /sbin/zpool not
> /sbin/zfs, because zpool (for me anyway) takes less time and if there's
> a pool there is going to be a filesystem (even if -omountpoint=none)
> that shows up /sbin/zfs).
> Note that this WILL result in the kernel modules being loaded.
> Depending on what the OP wants, you could use "/sbin/mount | grep zfs"
> instead, but that won't catch one situation: where all ZFS filesystems
> are mountpoint=none.
> Footnote: do not do silly things like grep /etc/src.conf for WITHOUT_xxx
> features, or /etc/rc.conf for whatever; an admin may have set these in
> advance for the next {build,install}{world,kernel} which have yet to be
> run.  Parsing/checking config files is not going to suffice.

That's a pretty awesome command, one which I've never heard of --
probably because it's only mentioned in these, and only these:


Not even in mount(8), VFS(9), extattr(9), or any other man page one
might think be relevant.  Strange, considering it's existed since
FreeBSD 2.0 (!).

| Jeremy Chadwick                                   jdc at |
| UNIX Systems Administrator       |
| Mountain View, CA, US                                            |
| Making life hard for others since 1977.             PGP 4BD6C0CB |

More information about the freebsd-questions mailing list