I have just setup NFS and it has been working fine after manually binding the shares to /srv/....
I edited my fstab according to the arch wiki but it appears to be causing an issue on reboot resulting in the nfs service failing to start. I'm almost certain it is an fstab issue going by my logs.
$this->bbcode_second_pass_code('', 'Sep 12 09:27:59 arch rpc.mountd[263]: Could not bind socket: (98) Address already in use
Sep 12 09:27:59 arch rpc.mountd[263]: Could not bind socket: (98) Address already in use
Sep 12 09:27:59 arch rpc.mountd[263]: Could not bind socket: (98) Address already in use
Sep 12 09:27:59 arch rpc.mountd[263]: Could not bind socket: (98) Address already in use
Sep 12 09:29:33 arch systemd[1]: Failed to start NFS server and services.
-- Subject: Unit nfs-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nfs-server.service has failed.
--
-- The result is failed.')
here is my fstab file, the bottom line is the bind for the nfs
$this->bbcode_second_pass_code('', '#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/sda /mnt/2tb_hd ext4 defaults,nofail,x-systemd.device-timeout=1 0 2
/mnt/2tb_hd /srv/nfs4/2tb_hd none bind 0 0')
------------------
Edit
I have tried the following but still having an issue starting the service.
$this->bbcode_second_pass_code('', '$ sudo systemctl disable nfs-server.service
Removed /etc/systemd/system/multi-user.target.wants/nfs-server.service
$ sudo systemctl stop nfs-server.service
$ sudo mount --bind /mnt/2tb_hd/ /srv/nfs4/2tb_hd/
$ sudo systemctl start nfs-server.service
Job for nfs-server.service failed because the control process exited with error code.
See "systemctl status nfs-server.service" and "journalctl -xe" for details.')
$this->bbcode_second_pass_code('', '$ systemctl status nfs-server.service
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2016-09-12 09:53:35 BST; 23s ago
Process: 617 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=1/FAILURE)
Process: 613 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Main PID: 617 (code=exited, status=1/FAILURE)
Sep 12 09:53:35 arch systemd[1]: Starting NFS server and services...
Sep 12 09:53:35 arch rpc.nfsd[617]: rpc.nfsd: unable to set any sockets for nfsd
Sep 12 09:53:35 arch systemd[1]: nfs-server.service: Main process exited, code=exited, status=1/FAILURE
Sep 12 09:53:35 arch systemd[1]: Failed to start NFS server and services.
Sep 12 09:53:35 arch systemd[1]: nfs-server.service: Unit entered failed state.
Sep 12 09:53:35 arch systemd[1]: nfs-server.service: Failed with result 'exit-code'.')
$this->bbcode_second_pass_code('', '$ journalctl -xe
--
-- Unit nfs-server.service has failed.
--
-- The result is failed.
Sep 12 09:53:35 arch systemd[1]: nfs-server.service: Unit entered failed state.
Sep 12 09:53:35 arch systemd[1]: nfs-server.service: Failed with result 'exit-code'.
Sep 12 09:53:35 arch systemd[1]: Stopping NFSv4 ID-name mapping service...
-- Subject: Unit nfs-idmapd.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nfs-idmapd.service has begun shutting down.
Sep 12 09:53:35 arch systemd[1]: Stopping NFS Mount Daemon...
-- Subject: Unit nfs-mountd.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nfs-mountd.service has begun shutting down.
Sep 12 09:53:35 arch rpc.mountd[612]: Caught signal 15, un-registering and exiting.
Sep 12 09:53:35 arch systemd[1]: Starting Notify NFS peers of a restart...
-- Subject: Unit rpc-statd-notify.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit rpc-statd-notify.service has begun starting up.
Sep 12 09:53:35 arch sudo[597]: pam_unix(sudo:session): session closed for user root
Sep 12 09:53:35 arch systemd[1]: Stopped NFSv4 ID-name mapping service.
-- Subject: Unit nfs-idmapd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nfs-idmapd.service has finished shutting down.
Sep 12 09:53:35 arch sm-notify[623]: Version 1.3.3 starting
Sep 12 09:53:35 arch sm-notify[623]: Already notifying clients; Exiting!
Sep 12 09:53:35 arch systemd[1]: Stopped NFS Mount Daemon.
-- Subject: Unit nfs-mountd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nfs-mountd.service has finished shutting down.
Sep 12 09:53:35 arch systemd[1]: Started Notify NFS peers of a restart.
-- Subject: Unit rpc-statd-notify.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit rpc-statd-notify.service has finished starting up.
--
-- The start-up result is done.')
-------------
Edit.
After disabling the service, commenting out the bind in fstab and rebooting the system I can manually bind and start the service. Sometimes it can take a while for sda to mount after reboot with the fstab configuration but it does eventually mount.
$this->bbcode_second_pass_code('', 'arch systemd[1]: Timed out waiting for device dev-sda.device.')
for now I have added the following alias but I would like to have it start on boot if possible.
$this->bbcode_second_pass_code('', 'alias startnfs='sudo mount --bind /mnt/2tb_hd/ /srv/nfs4/2tb_hd/ && sudo systemctl start nfs-server.service'')