What is the best way to stop nfs server?

Hello there,
I run a router Linksys WRT32x with Openwrt 19.07.3.
I have a USB HDD connected to router USB3 with nfs protocol.
This is working fine.
I want to be able to reposition the disk with another.
Server side, I set up similar mount lines in /etc/config/fstab and /etc/exports

~# cat /etc/config/fstab

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option uuid 'd54b056a-c1bf-4bb9-b2cd-16ab178010b2'
	option target '/mnt/hd5'
	option options 'async,noatime'
	option enabled '1'

config mount
	option uuid 'c6584879-c77b-42c6-9acf-a3996fb15442'
	option target '/mnt/hd6'
	option options 'async,noatime'
	option enabled '0'

~# cat /etc/exports
/mnt/hd5	192.168.1.0/255.255.255.0(rw,all_squash,async,no_subtree_check,fsid=0)
/mnt/hd6	192.168.1.0/255.255.255.0(rw,all_squash,async,no_subtree_check,fsid=0)

Client side, I set up 2 mount path, /mnt/HD5 and /mnt/HD6 and in /etc/fstab

~> cat /etc/fstab
...
192.168.1.1:/mnt/hd5                       /mnt/HD5    nfs4    rw,async,wsize=65536,rsize=65536              0  0
192.168.1.1:/mnt/hd6                       /mnt/HD6    nfs4    rw,async,wsize=65536,rsize=65536              0  0

I tried to change it and stopped nfs, unmounted /mnt/hd5.
Unfortunately I could not mount HD6 in the client even after 5 hours try.
I always got error message: mount.nfs: Stale file handle

My question is: What is the good way to stop nfs without savagely breaking connection between server/client and avoid this error message?

Thank you

1 Like

Thank you for your help but...
Only 1 computer running
Started with a working conf, HD5 connected to router, share with nfs working from client.
Client side:

~> umount /mnt/HD5

~> lsof | grep /mnt
~> lsof | grep /HD

Nothing returned
Server side:

~# /etc/init.d/nfsd stop
~# umount /mnt/hd5

Disconnect HD5 USB, connect HD6 USB
From LuCi GUI, Enable HD6 UUID, click "Mount attached devices" => /dev/sda1, /mnt/hd6 mounted
Client CLI:

:~> sudo mount /mnt/HD6
mount.nfs4: Stale file handle

My question is: How to properly stop the nfs share to avoid the error message?

BTW, after that I tried step by step, very carefully, the 3 different processes in the links you provided. No one succeeded!
The one with "vi /var/lib/nfs/rmtab" has not be done as I don't have rmtad file in Opensuse.

Now I am back with HD5 working, this one is an easy step.

Any idea?

Check open files and network connections on both sides with lsof, netstat or ss.
Sometimes there's no other option than forcefully terminate the stale processes.
In other cases, you may need to log off the client session or restart the corresponding daemon back-end, e.g. GVFS-NFS.

I spent few more hours to fix the issue. No way!
Still get the "mount.nfs4: Stale file handle"
Rebooted both server and client, unmout/mount, tried all I found in Internet, nothing working.

Question: As I think I'll reinstall Openwrt, do you think I can reload the config backup after reinstall and not get the error again from the config backup?

I checked the config and nothing seems to keep the information about external hosts.
I umounted HD5 and reinstalled Openwrt on the router, keeping the config., Rebooted with the reinstalled packages and rebooted without HD5 but with HD6.
Self mounted at boot, restarted nfs. OK server side
Client showmount shows both hd5 and hd6. Tried to mount HD6 but... mount.nfs4: Stale file handle

Should I reinstall all the clients!!!!????
I feel hopeless!
Now I really need help with working fix!

Edit:
I tried to mount HD6 from RPi2/LibreElec and from a Opensuse laptop, same issue. I can't understand from where the issue is, server or client.

As I wrote in my previous post, I installed a brand new Openwrt.
Error is still here, so I could say the error is due to the client.
I installed brand new LibreElec/Kodi on a SD card. First time run I tried to connect to the router with nfs, I got the error

2020-08-03 17:58:18.338 T:1937219600   DEBUG: NFS: Context for 192.168.1.1/mnt/hd6 not open - get a new context.
2020-08-03 17:58:18.354 T:1937219600   ERROR: NFS: Failed to mount nfs share: /mnt/hd6 (mount_cb: NFS: FSINFO of /mnt/hd6 failed with NFS3ERR_STALE(-116))
2020-08-03 17:58:18.355 T:1937219600   ERROR: GetDirectory - Error getting nfs://192.168.1.1/mnt/hd6/
2020-08-03 17:58:18.355 T:1937219600   ERROR: CGUIDialogFileBrowser::GetDirectory(nfs://192.168.1.1/mnt/hd6/) failed
2

So I could say the error is due to the server!!!!????
:upside_down_face:
:worried: :rage: :right_anger_bubble:

Have you changed the server export table /etc/exports to export /mnt/hd6 instead of (or as well as) /mnt/hd5?

Generally when upgrading a server drive copy all the data over then keep the name the same on the new one.

Thank you mk24, you gave me the start for a fix.
I have the solution!

To unblock the situation, I had to disconnected HD5 and reconnected HD6 then,
from the GUI I changed the mount point from /mnt/hd6 to /mnt/hd5 for HD6 UUID. At that time I had twice /mnt/hd5 in /etc/config/fstab

 cat /etc/config/fstab

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option uuid 'd54b056a-c1bf-4bb9-b2cd-16ab178010b2'
	option target '/mnt/hd5'
	option options 'async,noatime'
	option enabled '1'

config mount
	option uuid 'c6584879-c77b-42c6-9acf-a3996fb15442'
	option options 'async,noatime'
	option target '/mnt/hd5'
	option enabled '1'

Then I mounted, restated nfsd, exported and from the client mounted the HD5. Everything was working fine with /mnt/HD5. :smiley:
Then client unmounted, server unmounted, export -ua.
Then from CLI, I changed back the /mnt/hd5 to /mnt/hd6 and now I have

cat /etc/config/fstab

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option uuid 'd54b056a-c1bf-4bb9-b2cd-16ab178010b2'
	option target '/mnt/hd5'
	option options 'async,noatime'
	option enabled '1'

config mount
	option uuid 'c6584879-c77b-42c6-9acf-a3996fb15442'
	option options 'async,noatime'
	option target '/mnt/hd6'
	option enabled '1'

mount, export in server and mount in client. Now it's working fine. :laughing:
Now I can change the HDD with one CLI on client and the other SSH to server:
Unset:
Client:

sudo showmount -e MainRouter
df
sudo umount /mnt/HDx
df

Server:

exportfs
showmount -e MainRouter
exportfs -ua
exportfs
showmount -e MainRouter
df
block umount /mnt/hdx
df

Disconnect HDDx
Reconnect new HDDy
Set:
Server:
The new HDD will auto-mount

df
exportfs -a
showmount -e MainRouter
exportfs
df

Client:

sudo showmount -e MainRouter
df
sudo mount /mnt/HDy
df

I hope this will help.
Thank you all for your support.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.