7

I'm building a somewhat minimalistic system that collects serial port data and shoves it into a logfile on an NFS mount.

In an effort to reduce the system somewhat I decided to disable RPC as I couldn't see the use for it, and this resulted in the following warning:

mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

No suprise that RPC was involved in NFS, really, so my next step is to remove the warning. I have the choice of either re-enabling RPC, or use -o nolock as suggested.

So the question is then, what does remote locking do, exactly? In this particular case, the NFS mount is only written to by the machine in question, and there is no potential for conflicts such as multiple processes writing to the same file. (although, there are several processes writing to each their own logfile)

Running debian buster, kernel 4.19

EDIT: I tried -o nolock, and things seem to be working fine, so at first glance, there are no adverse effects.

Jarmund
  • 535
  • 1
  • 6
  • 16

1 Answers1

6

The answer lies in the good old man page of rpc.statd:

File locks are not part of persistent file system state. Lock state is thus lost when a host reboots.

Network file systems must also detect when lock state is lost because a remote host has rebooted. After an NFS client reboots, an NFS server must release all file locks held by applications that were running on that client. After a server reboots, a client must remind the server of file locks held by applications running on that client.

For NFS version 2 [RFC1094] and NFS version 3 [RFC1813], the Network Status Monitor protocol (or NSM for short) is used to notify NFS peers of reboots. On Linux, two separate user-space components constitute the NSM service:

rpc.statd

A daemon that listens for reboot notifications from other hosts, and manages the list of hosts to be notified when the local system reboots

sm-notify

A helper program that notifies NFS peers after the local system reboots

So basically, rpc.statd running on the NFS server prevents processes running on other NFS clients from accessing files you've locked from your client machine. As long as there's only one client, local locks are fine. But usually NFS is all about sharing.

wazoox
  • 6,782
  • 4
  • 30
  • 62