How to add zfs support to FreeBSD

Teske, Devin Devin.Teske at fisglobal.com
Tue Feb 19 09:09:15 UTC 2013


4. lsvfs output?
-- 
Devin

________________________________________
From: owner-freebsd-questions at freebsd.org [owner-freebsd-questions at freebsd.org] on behalf of Jeremy Chadwick [jdc at koitsu.org]
Sent: Tuesday, February 19, 2013 12:16 AM
To: freebsd-questions at freebsd.org
Cc: fbsd8 at a1poweruser.com; freebsd at edvax.de
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.

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

_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

_____________
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.


More information about the freebsd-questions mailing list