17

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

3

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.

5
  • 1
    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.
    – MJD
    Jul 18, 2013 at 21:30
  • could you give an example of trying to reattach and it not working? maybe with mount -a?
    – bkanuka
    Jul 19, 2013 at 13:37
  • 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.
    – MJD
    Jul 19, 2013 at 19:58
  • 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?
    – bkanuka
    Jul 21, 2013 at 12:35
  • 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.
    – MJD
    Jul 23, 2013 at 21:16
0

Perhaps you can tweak the timeo and retrans options of the NFS mounts to achieve the desired behavior. See the nfs man page for more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .