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.

George M
  • 13,589
  • 4
  • 43
  • 53
MJD
  • 279
  • 1
  • 2
  • 5

2 Answers2

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.

bkanuka
  • 163
  • 7
  • 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 '13 at 21:30
  • could you give an example of trying to reattach and it not working? maybe with `mount -a`? – bkanuka Jul 19 '13 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 '13 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 '13 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 '13 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.

Kalle Richter
  • 2,100
  • 4
  • 20
  • 37
crayzeewulf
  • 109
  • 2