Score:0

NFS server not starting at boot time (Can be started manually)

th flag

Problem: I have an NFS server that fails to export directories on boot. Once booted I can ssh in and start the server manually. I have set all owner:group and permissions to be very "permissive, so as to avoid any permissions problems, these will be locked down later, when I have the problem fixed.

NOTE: This server is not accessible from outside my lan.

Output of systemctl status nfs-kernel-server.service

● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2023-02-20 10:22:36 GMT; 27min ago
  Process: 303 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)

Feb 20 10:22:36 file-server systemd[1]: Starting NFS server and services...
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Documents: No such file or directory
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Downloads: No such file or directory
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Video: No such file or directory
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Control process exited, code=exited status=1
Feb 20 10:22:36 file-server systemd[1]: Failed to start NFS server and services.
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Unit entered failed state.
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Failed with result 'exit-code'.

After I run systemctl start nfs-kernel-server.service

Output of systemctl status nfs-kernel-server.service

● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2023-02-20 10:51:34 GMT; 1min 4s ago
  Process: 735 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 732 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 735 (code=exited, status=0/SUCCESS)

Feb 20 10:51:33 file-server systemd[1]: Starting NFS server and services...
Feb 20 10:51:34 file-server systemd[1]: Started NFS server and services.

So I can start the service manually, but it will not start at boot.

Server info:

IP address - 192.168.1.200 (Assigned by DHCP, reserved IP on router)

sda ext4 mounted at boot as / and swap

sdb ext4 mounted at boot as /shared

/etc/fstab

#sda1
UUID=4c5189b4-6ed8-416a-9b45-d7a8cb7d1f76 /               ext4    errors=remount-ro 0       1
#sda2
UUID=85704cdf-46ff-4a71-83a0-deebf37f9f82 none            swap    sw              0       0

#sdb1
UUID=98c91985-fe1b-43d0-8c62-a6edb9184a35 /shared ext4 nofail,sync,auto,noexec,nosuid,rw,nouser 1 2

/etc/exports

/shared/Video 192.168.1.0/24(rw,sync,no_subtree_check)
/shared/Downloads 192.168.1.0/24(rw,sync,no_subtree_check)
/shared/Documents 192.168.1.0/24(rw,sync,no_subtree_check)

owner/permissions of mountpoint (/shared)

drwxrwxrwx 7 nobody nogroup 4096 Aug 18  2022 /shared/

owner/permisions of /shared/*

drwxrwxrwx  27 nobody nogroup 12288 Jan 26 19:45 /shared/Documents/
drwxrwxrwx  25 nobody nogroup  4096 Aug 18  2022 /shared/Downloads/
drwx------   2 root   root    16384 Aug 18  2022 /shared/lost+found/
drwxrwxrwx 162 nobody nogroup 12288 Feb  4 15:03 /shared/Video/

(Obviously lost+found is NOT shared. The owner:group and permissions are set recursively)

I can provide any additional info requested.

David avatar
th flag
P.S. Any advice regarding ownership, and permission would be gratefully accepted :)
Score:1
sa flag

Looks like your nfs server starts before mounting /shared filesystem. You should change .service file. As exemplem you could check this or this answers, or read systemd documentation.

David avatar
th flag
Thank you. I added RequiresMountsFor=/shared to the unit section of /lib/systemd/system/nfs-kernel-server.service. Hopefully the correct place. I have searched for this and have found posts that suggest changing the "legacy" init.d scripts, but these changes might be ineffective when Debian(gets it's arse into gear) and changes these legacy scripts for a pure systemd solution. I have upvoted and marked as solution.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.