# Unreachable NFS mount causes hang for df control



## vecihi (May 22, 2014)

Hello,

Platform: FreeBSD host 8.3-STABLE FreeBSD 8.3-STABLE #3: Wed Jan 23 14:54:55 EET 2013

I mounted an NFS share with `172.16.1.144:/home/share/pub on /media/nfs (nfs)` The problem is if I stop the NFS service on 172.16.1.144 machine. And if I run `df -kh`, this command causes a hang and if I run disk usage checks every five minutes, each `df` call means a new hanging process.

How can I prevent this hanging problem for `df` checks if the NFS share is not reachable?

Kind regards


----------



## SirDice (May 22, 2014)

Why don't you unmount the filesystems _before_ you stop the NFS server?


----------



## vecihi (May 22, 2014)

SirDice said:
			
		

> Why don't you unmount the filesystems _before_ you stop the NFS server?



NFS server connectivity problem is unexpected stuiation so I can't unmount it. By using `df -t nonfs -kh` command didn't solve the problem.

Regards


----------



## SirDice (May 22, 2014)

There are the intr and soft options for mount_nfs(8) but:

```
Since nfsv4 performs open/lock operations that have their ordering
     strictly enforced by the server, the options intr and soft cannot be
     safely used.  hard nfsv4 mounts are strongly recommended.
```


----------



## vecihi (May 22, 2014)

`df -t nonfs -kh` command didn't solve the problem.


```
python 32950 [rpccon] 7.05r 0.00u 0.00s 0% 1676k
```

Do you have another suggestion?


----------



## ralphbsz (May 24, 2014)

SirDice said:
			
		

> There are the intr and soft options for mount_nfs(8) but:
> 
> ```
> Since nfsv4 performs open/lock operations that have their ordering
> ...



True.  That's one of the drawbacks of NFSv4.  But: The OP is probably not using NFSv4.

Here is my suggestion: Make sure you are using NFSv2 or NFSv3.  Then, you have to make a decision whether you want your system to be able to operate when the NFS server is not available.  In many situations, there is no point trying to operate without the NFS server, and waiting for it to come back up is the right answer.  In that case, mount the NFS file system with option "hard".  In the case of the OP, he seems to be wanting to be able to operate without the NFS server, so he should mount with option "soft".

But: If he does that, he needs to think about all the places where he uses that NFS file system, and he needs to make sure all of them do the right thing if the file system is not present.


----------

