Linux nfs client restart

Forcing Linux NFS client to reconnect to server after NFS is disconnected

Is there a way to force a Linux client to reconnect to a NFS server after it has lost its connection? The client eventually notices the server is back and resumes working just fine. I’m just wondering if there is a way to speed up this re-connection.

2 Answers 2

You could look into Autofs (ArchWiki link). If you setup the NFS to automount, the client should try to (re)connect to the NFS drive every time you try to use it. This would ensure that if you try to access the NFS drive from the client and the server is up, then the NFS drive will attach.

Thanks for the answer. This doesn’t help in this, case the share is already mounted and the client is already talking to the server. Sometimes, I kill the connection (it is only between a couple of my personal systems), and when I reestablish the link I’d like to kill the timeout period. Autofs wouldn’t help in this, or if it would speed up the re-connection, it would be nice to know how it did as I’d like to do that manually.

I think you misunderstanding what I’m doing. I don’t unmount the nfs volume between before disconnecting the networks. In this case it is fine, as it is just between my personal stuff, and I rather have the processes reading files off the NFS mount point to sleep then fail. When I reconncet the network, there is a timeout period before the client re-finds the server. That timeout period is what I want to kill, since I know the server is back. The timeout isn’t too bad, but it is a little annoying.

Читайте также:  Linux partitioning and formatting

hmm. I am misunderstanding something. Now I’m imagining you have a laptop and a home server, and sometimes you like to just grab the laptop and go. When you return, you reconnect to your home network. and then wait. and finally your NFS shares attach again. Am I right?

Well, sort of. Except the laptop is the NFS server, and a Desktop is the client. And if I’m leaving with my laptop, I don’t care if half the desktop freezes over the lost of its server (and it does . ). Since half the desktop if frozen, I’d like to speed up that reconnection. I have a feeling I’m abusing NFS, so I figured there is no way to help me. Since its just an annoyance, I’m not concerned.

Источник

reinit NFS client without restart

I have been working on my server, from which I export one directory using NFS. Of course over the week or so of server reboots, I multiple times forgot to umount the export filesystem in my workstation (which gets mounted from /etc/fstab on boot). In between I was able to umount after the fact and remount (I am not using autofs ):

umount -fl /data0 mount /data0 

But this no longer works. I cannot mount the exported directory from the server on a different directory (mount hangs), but I can nfs mount that exported dir on a virtual machine running on my workstation. What I tried is removing ( rmmod ) the nfs and nfsv3 module (which would not work: Resource temporarily unavailable ). lsof hangs. mount doesn’t show anything mounted via nfs . This is all probably a result of using ‘umount -l’ multiple times, but the first two times this worked without a problem. I have restarted the server in the mean time, after not being able to mount without that making any difference. I also used service nfs-kernel-server restart . I suspect everything would be back to normal if I restart the client workstation. Is there a way to recover from this and reinitialise the nfs client side on my workstation without a reboot?
If I cannot fix this without reboot, would this not reoccur if I start using autofs ? lsof -b hangs with as last lines:

lsof: avoiding readlink(/run/user/1001/gvfs): -b was specified. lsof: avoiding stat(/run/user/1001/gvfs): -b was specified. lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs Output information may be incomplete. 
192.168.0.2:/data0 /data0 nfs defaults,auto,nolock,user 0 2 

Источник

Оцените статью
Adblock
detector