1

I have an NFS server on a Pi 4 which works rather well except I'm often getting "Stale file handle" on the client after rebooting the Pi. That is while the client has the share mounted, the Pi reboots, upon it being booted the client spits out the error when trying a file operation like ls. What's causing this and how can I fix it?

2

The problem is that the filesystem that's exported by NFS isn't always ready when NFS starts. In this particular case, there's an external disk that is asynchronously mounted on boot and sometimes NFS starts before that happens. The result is that NFS can't export the filesystem.

One good solution is to use systemd to create a dependency between NFS and the filesystem. There are multiple ways to do this but perhaps the simplest is:

  1. Open /etc/fstab and
  2. Add the option x-systemd.before=nfs-server.service to the mount options for the filesystem

Once complete, nfs-server.service will only be started after the filesystem is mounted and will therefore successfully export it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.