Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharenfs=on does not work during boot #1375

Closed
boydc2014 opened this issue Mar 29, 2013 · 23 comments
Closed

sharenfs=on does not work during boot #1375

boydc2014 opened this issue Mar 29, 2013 · 23 comments

Comments

@boydc2014
Copy link

I use:

zfs set sharenfs=on mypoolname

to share filesystem over nfs, and "showmount -e" shows it works

but After reboot, "showmount -e" shows than there is no share filesystem, I must mannuly set sharenfs=on again.

Should the sharenfs option works during boot or is there some configuration i miss?

It's on CentOS6.3, thanks in advance

@behlendorf
Copy link
Contributor

This should work, but it wouldn't surprise me that there are some some integration gremlins here. If your having trouble with this you might just set sharenfs=off and manually configure NFS as usual for your Linux system.

@timkent
Copy link

timkent commented Apr 4, 2013

I am also having this issue on Ubuntu 12.04 (LTS)

@criefel
Copy link

criefel commented Apr 5, 2013

This is a Problem on Ubuntu 12.04 (LTS), it occures one "some" reboots, not on every.
Any hint for debugging, logfiles?

@ssmy
Copy link

ssmy commented Apr 19, 2013

Seeing this as well on Ubuntu 12.04. I just set it to on again and it started working. Notably, it was when the version of zfs had changed. Not sure if related though, since it's the first time I have restarted it.

@igmgit
Copy link

igmgit commented Apr 30, 2013

Seems like an issue with /etc/init.d/zfs-share & /etc/default/zfs & ZFS_MOUNT="no"

I couldn't get it working using /etc/default/zfs. I finally just put "zfs mount -a && zfs share -a" into /etc/rc.local

@tesujimath
Copy link
Contributor

Hi,

I'm also on EL 6 (CentOS). The reason for the shares not exporting on boot is that the zfs share -a command in the zfs startup script happens too early (01 in the sequence). It needs to happen after NFS is started (which is 30). I have split out the share command into a separate startup script (zfs-share), which I start at 35 in the sequence.

Initial testing shows this to work nicely. Will contribute via a pull request when fully tested.

cheers,
Simon

@behlendorf
Copy link
Contributor

@tesujimath Looking forward to the pull request, thanks for digging in to this.

@theogfx
Copy link

theogfx commented Feb 3, 2014

I also confirm the issue on Ubuntu Server 12.04 (x64). Putting zfs share -a in /etc/rc.local solved the problem (as @igmgit suggested).

@FransUrbo
Copy link
Contributor

@boydc2014 ok, so can we close this as a non-issue then?

@behlendorf
Copy link
Contributor

@tesujimath Did you ever open a pull request for this. I don't see one.

@tesujimath
Copy link
Contributor

@behlendorf Not yet, sorry, have been flat out too busy. Sorry for the delay. Will try to do it later today. It definitely needs a fix, as expecting users to fiddle around with /etc/rc.local is unacceptable in my view.

@FransUrbo
Copy link
Contributor

@behlendorf Would there be interest in merging all the initscripts AND separating mount and share into two?

I'm looking at the five (!!) init scripts in the repo, and they're almost identical. Only some very small differences separates them.

I'd be happy to do the work of replace ALL of them with two scripts that should work with all distributions.

@behlendorf
Copy link
Contributor

@tesujimath A small fix would be great.

@FransUrbo Fewer scripts would be good and I'd love to retire them in favor of something simpler Perhaps this is something for the next tag since testing the scripts on all the platforms is a pretty laborious task. Also the systemd work in #2098 will make some of those scripts obsolete for systemd based systems. And at least a large part of the Linux ecosystem seems to be heading that way.

@tesujimath
Copy link
Contributor

@FransUrbo If you want to take this on, that's great. Here's my patch file (against 0.6.2 release) for the startup script I'm using on CentOS 6, if it helps, I'd be grateful, as I don't really have time to push this stuff up through git just now (Merge conflicts, aarrgg! I've obviously not got an efficient workflow for submitting changes through git - I probably need to start using branches for this.) Anyway, here's my patch:

diff -uNr init.d.dist/zfs init.d.sjg/zfs
--- init.d.dist/zfs 2014-01-17 11:32:22.982478614 +1300
+++ init.d.sjg/zfs  2014-01-17 11:32:22.984478599 +1300
@@ -97,8 +97,6 @@

    action $"Mounting automounted ZFS filesystems: " $ZFS mount -a || return 152

-   action $"Exporting ZFS filesystems: " $ZFS share -a || return 153
-
    # Read fstab, try to mount zvols ignoring error
    read_fstab "^/dev/(zd|zvol)"
    template=$"Mounting volume %s registered in fstab: "
diff -uNr init.d.dist/zfs-share init.d.sjg/zfs-share
--- init.d.dist/zfs-share   1970-01-01 12:00:00.000000000 +1200
+++ init.d.sjg/zfs-share    2014-01-17 11:23:10.133267819 +1300
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# zfs-share     This script will share the zfs filesystems.
+#
+# chkconfig:    2345 35 65
+#
+# description:  This script will share the zfs filesystems during
+#               system boot.  Configuration of which filesystems  
+#               should be shared and how is handled by the zfs
+#               'sharenfs' property.  See the zfs(8) man page for
+#               details.
+#
+### BEGIN INIT INFO
+# Provides: zfs-share
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+# Short-Description: Share the zfs filesystems
+# Description: ZFS is an advanced filesystem designed to simplify managing
+#              and protecting your data.  This service mounts the ZFS
+#              filesystems and starts all related zfs services.
+### END INIT INFO
+
+export PATH=/usr/local/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
+
+if [ -z "$init" ]; then
+    # Not interactive
+    grep -Eqi 'zfs=off|zfs=no' /proc/cmdline && exit 3
+fi
+
+# Source function library & LSB routines
+. /etc/rc.d/init.d/functions
+
+# script variables
+RETVAL=0
+ZFS="/sbin/zfs"
+ZPOOL="/sbin/zpool"
+servicename=zfs
+LOCKFILE=/var/lock/subsys/$servicename
+
+# functions
+zfs_installed() {
+   modinfo zfs > /dev/null 2>&1 || return 5
+   $ZPOOL  > /dev/null 2>&1
+   [ $? == 127 ] && return 5
+   $ZFS    > /dev/null 2>&1
+   [ $? == 127 ] && return 5
+   return 0
+}
+
+start()
+{
+   action $"Exporting ZFS filesystems: " $ZFS share -a || return 153
+}
+
+stop()
+{
+   # nothing to do
+   :
+}
+
+# See how we are called
+case "$1" in
+   start)
+       start
+       RETVAL=$?
+       ;;
+   stop)
+       stop
+       RETVAL=$?
+       ;;
+   status)
+       RETVAL=0
+       ;;
+   restart)
+       stop
+       start
+       ;;
+   condrestart)
+       if [ -f "$LOCKFILE" ] ; then
+           stop
+           start
+       fi
+       ;;
+   *)
+       echo $"Usage: $0 {start|stop|status|restart|condrestart}"
+       RETVAL=3
+       ;;
+esac
+
+exit $RETVAL

@behlendorf
Copy link
Contributor

@tesujimath You can use the following syntax to get a nice inline diff.

<your patch>

@tesujimath
Copy link
Contributor

@behlendorf Thanks! Do you still want a pull request for this, or is @FransUrbo going to do the legwork on merging startup scripts?

@behlendorf
Copy link
Contributor

@tesujimath It would be great if @FransUrbo could rework the init scripts to include your change and refactor them. My only concern is that there isn't enough time for this cleanup to be done and tested before the next tag.

@FransUrbo
Copy link
Contributor

I've already started merging all the scripts into one (actually two - one 'import+mount' script and one 'share' script that is designed to run at different priority). But I'm all for this going into 0.6.4, it's going to take a lot of testing before we can deem this safe to use!

In the mean time, I pushed #2103 which is a super-minor improvement to the current LSB script.

@tesujimath the diff you posted is, in my opinion, a little to much to go into 0.6.3, this is exactly the thing I'm working on. So for the next release, I'm afraid we'll have to do with what we have now :(.

@tesujimath
Copy link
Contributor

@FransUrbo OK. Glad to hear you're addressing this in general. When 0.6.3 comes along, then, I'll probably post another patch here to make the share=on work on boot. I'll have to do that for my own systems anyway.
@behlendorf I won't make a pull request for this after all then.

@FransUrbo
Copy link
Contributor

I pushed my first attempt at this (#2106) - the scripts probably don't even work on ANY system, but I'd appreciate if people could take a look at them and test them. I don't have any test environment at the moment, so I can't do it myself.

The difficult thing is to make something that works on all different systems (Fedora, RedHat, Debian GNU/Linux based and Gentoo which I have no experience in).

Any comment about the script(s) should be done in the pull request, not here.

In my opinion, this bug can (should!) be closed since it isn't a problem with ZoL, but with the boot process of the specific distribution.

@behlendorf
Copy link
Contributor

@FransUrbo That was fast. Why don't we create a tracking bug to fix up the init scripts and then we can close out these various issues as duplicates of that issue.

@FransUrbo
Copy link
Contributor

He, well doing cut-and-paste doesn't take that long :).

I took something that had the base functionality I needed and then just took what seemed appropriate from the existing.

Tracking bug #2107 added.

@behlendorf
Copy link
Contributor

OK, I'm closing this one out. We can finish up the proposed with in the new tracking bug. I believe the problem here is well understood. @tesujimath thanks for the proposed script.

@behlendorf behlendorf modified the milestone: 0.6.7 Nov 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants