Many issues with NFS and ZFS

    • OMV 3.x
    • Many issues with NFS and ZFS

      Hello,

      I'm in trouble with NFS and ZFS. I have the strongly impression that the NFS implementation with export dir and binds are not working correctly (probably with ZFS) or there is somewhere a strange bug. So before I report something I would like opinions

      Scenario OMV 3.0.48, opendmediavault-zfs 3.0.4
      Clean system. zfs mounts on /mnt/tank0, no nfs enabled on gui, no /export, /etc/export empty, sharedir TVSeries
      Steps:
      1) systemctl status zfs-mount.service
      ● zfs-mount.service - Mount ZFS filesystems
      Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled)
      Active: active (exited) since Wed 2016-10-26 19:52:41 CEST; 40s ago
      Process: 3385 ExecStart=/sbin/zfs mount -a (code=exited, status=0/SUCCESS)
      Main PID: 3385 (code=exited, status=0/SUCCESS)
      CGroup: /system.slice/zfs-mount.service
      2) enable the NFS (nothing defined to be exported), reboot, all good
      3) adding one share (TVSeries). /export/TVSeries created and point to correct path.
      mount |grep -i export
      tank0/Media on /export/TVSeries type zfs (rw,relatime,xattr,posixacl)
      cat /etc/fstab |grep export
      /mnt/tank0/Media/TVSeries /export/TVSeries none bind 0 0
      4) reboot
      5) systemctl status zfs-mount.service
      ● zfs-mount.service - Mount ZFS filesystems
      Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled)
      Active: failed (Result: exit-code) since Wed 2016-10-26 20:06:36 CEST; 29s ago
      Process: 1790 ExecStart=/sbin/zfs mount -a (code=exited, status=1/FAILURE)
      Main PID: 1790 (code=exited, status=1/FAILURE)

      Oct 26 20:06:34 nasbox zfs[1790]: cannot mount '/mnt/tank0': directory is not empty
      Oct 26 20:06:35 nasbox zfs[1790]: cannot mount '/mnt/tank0/Media': directory is not empty
      Oct 26 20:06:36 nasbox systemd[1]: zfs-mount.service: main process exited, code=exited, status=1/FAILURE
      Oct 26 20:06:36 nasbox systemd[1]: Failed to start Mount ZFS filesystems.
      Oct 26 20:06:36 nasbox systemd[1]: Unit zfs-mount.service entered failed state.

      -mount |grep -i export
      /dev/sda1 on /export/TVSeries type ext4 (rw,relatime,errors=remount-ro,data=ordered)
      -cat /etc/fstab |grep export
      /mnt/tank0/Media/TVSeries /export/TVSeries none bind 0 0
      -cat /etc/exports
      # /etc/exports: the access control list for filesystems which may be exported
      # to NFS clients. See exports(5).
      /export/TVSeries pi-router(rw,fsid=1,subtree_check,insecure)
      # NFSv4 - pseudo filesystem root
      /export pi-router(ro,fsid=0,root_squash,no_subtree_check,hide)

      # ZFS automatic exports

      cat /etc/openmediavault/config.xml |grep -C7 export
      <freq>0</freq>
      <passno>0</passno>
      <hidden>1</hidden>
      </mntent>
      <mntent>
      <uuid>9037fff3-d77d-4369-8305-c2d05552caf3</uuid>
      <fsname>/mnt/tank0/Media/TVSeries</fsname>
      <dir>/export/TVSeries</dir>
      <type>none</type>
      <opts>bind</opts>
      <freq>0</freq>
      <passno>0</passno>
      <hidden>0</hidden>
      </mntent>
      </fstab>


      ZFS is working but not NFS (directory is empty)

      6) reboot again
      7) Delete the NFS share (only) and reboot
      8) systemctl status zfs-mount.service
      ● zfs-mount.service - Mount ZFS filesystems
      Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled)
      Active: failed (Result: exit-code) since Wed 2016-10-26 20:15:14 CEST; 23s ago
      Process: 1793 ExecStart=/sbin/zfs mount -a (code=exited, status=1/FAILURE)
      Main PID: 1793 (code=exited, status=1/FAILURE)

      Oct 26 20:15:13 nasbox zfs[1793]: cannot mount '/mnt/tank0': directory is not empty
      Oct 26 20:15:14 nasbox zfs[1793]: cannot mount '/mnt/tank0/Media': directory is not empty
      Oct 26 20:15:14 nasbox systemd[1]: zfs-mount.service: main process exited, code=exited, status=1/FAILURE
      Oct 26 20:15:14 nasbox systemd[1]: Failed to start Mount ZFS filesystems.
      Oct 26 20:15:14 nasbox systemd[1]: Unit zfs-mount.service entered failed state.

      mount |grep -i export
      /dev/sda1 on /export/TVSeries type ext4 (rw,relatime,errors=remount-ro,data=ordered)
      cat /etc/fstab |grep export
      /mnt/tank0/Media/TVSeries /export/TVSeries none bind 0 0
      cat /etc/exports
      # /etc/exports: the access control list for filesystems which may be exported
      # to NFS clients. See exports(5).
      # NFSv4 - pseudo filesystem root

      # ZFS automatic exports

      cat /etc/openmediavault/config.xml |grep -C7 export
      <freq>0</freq>
      <passno>0</passno>
      <hidden>1</hidden>
      </mntent>
      <mntent>
      <uuid>9037fff3-d77d-4369-8305-c2d05552caf3</uuid>
      <fsname>/mnt/tank0/Media/TVSeries</fsname>
      <dir>/export/TVSeries</dir>
      <type>none</type>
      <opts>bind</opts>
      <freq>0</freq>
      <passno>0</passno>
      <hidden>0</hidden>
      </mntent>
      </fstab>

      ls -l /export/
      total 4
      drwxr-xr-x 2 root root 4096 Oct 26 20:06 TVSeries
      root@nasbox:~# ls -l /export/TVSeries/
      total 0


      Everything is still there.

      9) Remove the lines from the /etc/openmediavault/config.xml,reboot. All are there expect the lines which I delete (of course :D )
      10) Remove the lines from /etc/fstab, reboot. Error on zfs-mount service exists. Directory on /export exists.
      11) Reboot on single mode, rename /mnt/tank0 to /mnt/tank0.old and reboot
      12) systemctl status zfs-mount.service
      ● zfs-mount.service - Mount ZFS filesystems
      Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled)
      Active: active (exited) since Wed 2016-10-26 20:25:56 CEST; 26s ago
      Process: 1789 ExecStart=/sbin/zfs mount -a (code=exited, status=0/SUCCESS)
      Main PID: 1789 (code=exited, status=0/SUCCESS)
      CGroup: /system.slice/zfs-mount.service

      Oct 26 20:25:56 nasbox systemd[1]: Started Mount ZFS filesystems.




      So.... conclusion, bad cleanup on /etc/fstab (and directories), blocking correct operation of ZFS, NFS is not working.

      Openmediavault bug or openmediavault-zfs bug? ?( ?( ?(
    • I had the same Problem.
      You have to use omv 3.0.58 not 59
      and after creation of the NFS Entrys go into the fstab and remove the Bindings.

      Now use this little script and create an '@reboot' Crontab entry of it
      Or create an SystemD Unit that is starting after ZFS has mounted
      Another possibility is to set the Bindings as noauto and Mount them after ZFS

      The whole Problem with NFS and ZFS is, that NFS forces the mount.bind to Create the Mountpoints if they not exists, because they are created before the tank is Mounted, ZFS stops because the Mountpoint contains Folder with these Bindings

      Shell-Script

      1. #!/bin/bash
      2. echo "Checking for ZFS"
      3. MOUNT=$(mount -l | grep zfs)
      4. if [[ $MOUNT =~ "tank" ]]; then
      5. echo "ZFS tank available"
      6. echo "Binding Folder 1..."
      7. mount --bind "/tank/Folder 1" "/export/Folder 1"
      8. echo "Binding Folder 2..."
      9. mount --bind "/tank/Folder 2" "/export/Folder 2"
      10. echo "Binding Folder 3..."
      11. mount --bind "/tank/Folder 3" "/export/Folder 3"
      12. fi
      Display All
    • According to this post

      unix.stackexchange.com/questio…em-in-ubuntu-16-04/301747

      systemd can read now extra options in fstab, they are documented at man systemd.mount

      So maybe try to add for each bind as says there

      x-systemd.requires=zfs-mount

      If this works this will require some change in env variables in omv or some code change to support better ZFS using nfs.
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server