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 j...@koitsu.org | | UNIX Systems Administratorhttp://jdc.koitsu.org/ | | Mountain View, CA, US| | Making life hard for others since 1977. PGP 4BD6C0CB | ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
RE: How to add zfs support to FreeBSD
4. lsvfs output? -- Devin From: owner-freebsd-questi...@freebsd.org [owner-freebsd-questi...@freebsd.org] on behalf of Jeremy Chadwick [j...@koitsu.org] Sent: Tuesday, February 19, 2013 12:16 AM To: freebsd-questions@freebsd.org Cc: fb...@a1poweruser.com; free...@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 j...@koitsu.org | | UNIX Systems Administratorhttp://jdc.koitsu.org/ | | Mountain View, CA, US| | Making life hard for others since 1977. PGP 4BD6C0CB | ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@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. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: How to add zfs support to FreeBSD
On Tue, Feb 19, 2013 at 09:09:07AM +, Teske, Devin wrote: 4. lsvfs output? -- Devin From: owner-freebsd-questi...@freebsd.org [owner-freebsd-questi...@freebsd.org] on behalf of Jeremy Chadwick [j...@koitsu.org] Sent: Tuesday, February 19, 2013 12:16 AM To: freebsd-questions@freebsd.org Cc: fb...@a1poweruser.com; free...@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. That's a pretty awesome command, one which I've never heard of -- probably because it's only mentioned in these, and only these: df(1) find(1) mount(2) nmount(2) umount(2) jail(8) 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 j...@koitsu.org | | UNIX Systems Administratorhttp://jdc.koitsu.org/ | | Mountain View, CA, US| | Making life hard for others since 1977. PGP 4BD6C0CB | ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: How to add zfs support to FreeBSD?
On 2/18/13 4:21 PM, Fbsd8 wrote: The handbook does not cover how to add zfs support. How is it done? Does this help you? https://wiki.freebsd.org/ZFS Best, --Glenn ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: How to add zfs support to FreeBSD?
On Mon, 18 Feb 2013 16:57:14 -0500, Fbsd8 wrote: Fbsd8 wrote: The handbook does not cover how to add zfs support. How is it done? Let me reword. If zfs is in the base system why does it not show up when I look for it this way? if config -x $( sysctl -n kern.bootfile ) | grep -q '^[[:space:]]*options[[:space:]]\{1,\}ZFS\'; then echo yes zfs is in the kernel fi Without the ability to check this, I strongly assume that if you enable ZFS as described in the Handbook, the module /boot/kernel/zfs.ko (part of the default system) will be loaded. That's why it won't show up in a sysctl query aimed at the _kernel_ itself -- because it isn't in the kernel. Also, sysctl -n kern.bootfile will return the actual kernel file, /boot/kernel/kernel, which is a binary. If the exact config list (from the kernel _configuration_ file) is not plain-text part of that file, grep will not find the text you're grepping for. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: How to add zfs support to FreeBSD?
Polytropon wrote: On Mon, 18 Feb 2013 16:57:14 -0500, Fbsd8 wrote: Fbsd8 wrote: The handbook does not cover how to add zfs support. How is it done? Let me reword. If zfs is in the base system why does it not show up when I look for it this way? if config -x $( sysctl -n kern.bootfile ) | grep -q '^[[:space:]]*options[[:space:]]\{1,\}ZFS\'; then echo yes zfs is in the kernel fi Without the ability to check this, I strongly assume that if you enable ZFS as described in the Handbook, the module /boot/kernel/zfs.ko (part of the default system) will be loaded. That's why it won't show up in a sysctl query aimed at the _kernel_ itself -- because it isn't in the kernel. Also, sysctl -n kern.bootfile will return the actual kernel file, /boot/kernel/kernel, which is a binary. If the exact config list (from the kernel _configuration_ file) is not plain-text part of that file, grep will not find the text you're grepping for. So the next question is there any sh script code I can use to check if zfs has been enabled by the rc.conf zfs_enable statement. I need to determine if zfs is enabled on the host. Thanks ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
RE: How to add zfs support to FreeBSD?
The tool for checking rc.conf(5) is my sysrc(8). It will eventually be part of base (it's already checked into HEAD at usr.sbin/sysrc -- but not installed by default unless WITH_BSDCONFIG is enabled when performing a build(7) or release(7) process). Currently, also available via ports in sysutils/sysrc I definitely recommend giving it a shot. There's essentially two ways to use it for your needs: 1. sysrc -n zfs_enable Returns YES for example. or... 2. For better performance, use the includes... #!/bin/sh . /usr/local/share/sysrc/sysrc.subr f_sysrc_get zfs_enable Returns YES for example. -- Devin From: owner-freebsd-questi...@freebsd.org [owner-freebsd-questi...@freebsd.org] on behalf of Fbsd8 [fb...@a1poweruser.com] Sent: Monday, February 18, 2013 5:41 PM To: Polytropon Cc: FreeBSD questions Subject: Re: How to add zfs support to FreeBSD? Polytropon wrote: On Mon, 18 Feb 2013 16:57:14 -0500, Fbsd8 wrote: Fbsd8 wrote: The handbook does not cover how to add zfs support. How is it done? Let me reword. If zfs is in the base system why does it not show up when I look for it this way? if config -x $( sysctl -n kern.bootfile ) | grep -q '^[[:space:]]*options[[:space:]]\{1,\}ZFS\'; then echo yes zfs is in the kernel fi Without the ability to check this, I strongly assume that if you enable ZFS as described in the Handbook, the module /boot/kernel/zfs.ko (part of the default system) will be loaded. That's why it won't show up in a sysctl query aimed at the _kernel_ itself -- because it isn't in the kernel. Also, sysctl -n kern.bootfile will return the actual kernel file, /boot/kernel/kernel, which is a binary. If the exact config list (from the kernel _configuration_ file) is not plain-text part of that file, grep will not find the text you're grepping for. So the next question is there any sh script code I can use to check if zfs has been enabled by the rc.conf zfs_enable statement. I need to determine if zfs is enabled on the host. Thanks ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@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. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: How to add zfs support to FreeBSD?
On Mon, 18 Feb 2013 20:41:19 -0500, Fbsd8 wrote: So the next question is there any sh script code I can use to check if zfs has been enabled by the rc.conf zfs_enable statement. I need to determine if zfs is enabled on the host. Even though the statement zfs_enable=YES may be part of /etc/rc.conf, it's still possible that the ZFS subsystem is _currently_ not running. So in my opinion you should check with something that relies on ZFS actually running. So there could be a difference between is enabled and is running. Regarding is enabled, you can easily check if the corresponding line in /etc/rc.conf is present. This could result in a false-positive answer regarding is running. For example, if I add zfs_enable=YES to /etc/rc.conf and check its presence (e. g. using grep), but I don't do anything else; I'll get this: % zfs internal error: failed to initialize ZFS library Here's an example from a system not running ZFS: /sbin/zfs /dev/null 21 if [ $? -eq 0 ]; then echo ZFS is currently running. else echo ZFS is currently _not_ running. fi Check on a system running ZFS. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org