From owner-freebsd-questions@FreeBSD.ORG Tue Feb 19 08:16:44 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CD63DF89 for ; Tue, 19 Feb 2013 08:16:44 +0000 (UTC) (envelope-from jdc@koitsu.org) Received: from qmta06.emeryville.ca.mail.comcast.net (qmta06.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:56]) by mx1.freebsd.org (Postfix) with ESMTP id A3811396 for ; Tue, 19 Feb 2013 08:16:44 +0000 (UTC) Received: from omta18.emeryville.ca.mail.comcast.net ([76.96.30.74]) by qmta06.emeryville.ca.mail.comcast.net with comcast id 28EX1l0011bwxycA68Gk83; Tue, 19 Feb 2013 08:16:44 +0000 Received: from koitsu.strangled.net ([67.180.84.87]) by omta18.emeryville.ca.mail.comcast.net with comcast id 28Gj1l0071t3BNj8e8GjCs; Tue, 19 Feb 2013 08:16:43 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 21B5573A1C; Tue, 19 Feb 2013 00:16:43 -0800 (PST) Date: Tue, 19 Feb 2013 00:16:43 -0800 From: Jeremy Chadwick To: freebsd-questions@freebsd.org Subject: Re: How to add zfs support to FreeBSD Message-ID: <20130219081643.GA27867@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1361261804; bh=J/y67NluuFUiluohXFJjR+AOhvvI56oWHj2Ct5ipIWo=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=l+UDjAOOJruCXPfRWa6ucnS/DsVHKpN/iVgLwIOWhzjK4IkCBIeD1nko/usfIbeEA /9Kiz9soSgtpYjJNK6hr10lNbqQ6xaFVSZiWZB68tMbk3nnlIKP1IWys5d4dikU+zL nfqWngdF5GoOHxfIQxKedTqqqdVKe4qFIei5LYm9zYWTre9YhGtVSiRKFmrg9fTrts zIcqvxrU1v3yq4nALJtEhCu1ZM0dQYiEJ870ttnyu3Li/jZSUF1N8Sa6GyGKdUF40T EWy/yhOEcNkes1XV7x3z08KmuR8DyFtsEeO1FS16PwK7aL5xsy3cC9yoHeiil9EHf4 5Qu6+dAZApkIw== Cc: fbsd8@a1poweruser.com, freebsd@edvax.de X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2013 08:16:44 -0000 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@koitsu.org | | UNIX Systems Administrator http://jdc.koitsu.org/ | | Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB |