Force unmount of NFS-mounted directory [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I have an NFS-mounted directory on a Linux machine that has hung. I’ve tried to force an unmount, but it doesn’t seem to work:
$ umount -f /mnt/data $ umount2: Device or resource busy $ umount: /mnt/data: device is busy
If I type » mount «, it appears that the directory is no longer mounted, but it hangs if I do » ls /mnt/data «, and if I try to remove the mountpoint, I get:
$ rmdir /mnt/data rmdir: /mnt/data: Device or resource busy
I agree, whoever voted to close this seriously confused. This problem has plagued me for years, and the answer below, umount -l, for Linux, is the first solution I’ve found that worked.
ok, but you could find it on Super User. although I don’t see why the question was not moved instead of closed.
For umount —force will try harder to unmount and -v or -vvv even will reveal more what is the problem with mount. So try: umount -vvv —force /badmount
@deeenes Because this question was asked in Sept. 2008, and Super User wasn’t launched until July 2009 😉
6 Answers 6
You might try a lazy unmount:
This made things worse for me, as I was still not able to suspend my machine. The solution with the eth0 alias and umount -f worked.
This worked for me (Slackware 14.0). I had a CIFS mount, not NFS, that was hanging everything (including lsof ). I caused the problem by breaking out of a backup script that I’m writing. The script mounts and unmounts the directory, but something about breaking out of rsync messed up my mount. I didn’t know about the lazy unmount. It may have been the NAS device causing all the trouble. After successfully unmounting, it turned out that I had to reboot the device before I could mount it again.
@KieranAndrews and anyone else on Ubuntu, try fusermount -uz /path/to/file . Worked a charm for me! 🙂
Linux umount force nfs
NAME
umount.nfs, umount.nfs4 - unmount a Network File System
SYNOPSIS
umount.nfs dir [-fvnrlh ]
DESCRIPTION
umount.nfs and umount.nfs4 are a part of nfs(5) utilities package, which provides NFS client functionality. umount.nfs4 and umount.nfs are meant to be used by the umount(8) command for unmounting NFS shares. This subcommand, however, can also be used as a standalone command with limited functionality. dir is the directory on which the file system is mounted.
OPTIONS
-f Force unmount the file system in case of unreachable NFS system. -v Be verbose. -n Do not update /etc/mtab. By default, an entry is created in /etc/mtab for every mounted file system. Use this option to skip deleting an entry. -r In case unmounting fails, try to mount read-only. -l Lazy unmount. Detach the file system from the file system hierarchy now, and cleanup all references to the file system as soon as it is not busy anymore. -h Print help message.
NOTE
For further information please refer nfs(5) and umount(8) manual pages.
FILES
/etc/fstab file system table /etc/mtab table of mounted file systems
SEE ALSO
AUTHOR
© 2019 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.
How to unmount NFS when server is gone?
I am mounting a NFS-folder from a server to my laptop. Unfortunately, the server goes off sometimes. The problem is, that I cannot unmount the «dead» NFS-folder. On the command-line, I get «device is busy», and via nautilus it crashes my current session. Is there any way to unmount a NFS-folder when the server is off?
6 Answers 6
You can use umount -f -l /mnt/myfolder , and that will fix the problem.
- -f – Force unmount (in case of an unreachable NFS system). (Requires kernel 2.1.116 or later.)
- -l – Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)
Source:Linux Complete Command Reference
try sudo umount -l to do a «lazy unmount». Lets you move on with your life without waiting for the plumber to arrive.
In my case where umount -f did not work, umount -fr worked. -r argument remounts as read-only and then unmounts the folder.
In case umount -f -l /mnt/myfolder doesn’t work service nfs restart (or it’s equivalent on your linux) might.
The problem with this is if you have several nfs mounted paths from different servers and you don’t want to drop other mount points which would affect other services.
For me, neither umount, nor service restart will work. Just reboot. Even with a new system, NFS implementation seems to still have that old issue. So, just reboot.
I noticed something when trying to unmount directories for NFS servers that go offline.
My first instinct is to unmount lowest subdirectories first and then work my way up to the top of the directory tree. However, unmounting subdirectories by using —force and —lazy failed and resulted in a long timeout. What finally worked for me was when I used —force and —lazy at the top level, as in:
umount --lazy --force /net/machine
Don’t first try to unmount the lower directories, such as:
umount --lazy --force /net/machine/subdir
Force unmount NFS partition
I need weapons, I have none. I have a NFS mountpoint in my system which isn’t responding to anything. The physical mountpoint doesn’t even exist anymore, but the system doesn’t know it’s not there anymore. I’ve tried the typical
umount -l /partition umount -f /partition fuser -km /partition
The command just stucks there and does nothing. From time to time I have encountered this kind of behaviour, but usually the mountpoints get sorted by themselves. I’d just like to know the reason behind this and to make sure that I’ve tried everything. Currently the behaviour messes up my filesystem since there are several mountpoints mounted under the same subfolder.
I think to many reasons that can cause it. Traffic on the remote LAN, remote server jammed, traffic on the backbone between you and the remote server, remote server down, remote server reinstalled, remote server with changed IP. try to ping or traceroute the remote server.
2 Answers 2
We have had a similar issue as well. We have a server that has a NFS mount to another server. When the target is rebooted it will cause the client to just hang. umount force and lazy don’t work. Our only recourse is to remove/comment the entries in fstab and force a restart on the client making sure the host is up. The NFS won’t be mounted when it comes back up.
Unfortunately even at this time the Linux implementation of NFS is very bad at handling lost connections to servers. This does not happen in many other UNIX variants, but for some reason seems to be hard to fix in Linux, or nobody seems to bother.
What I usually do to get it sorted is to use also the -r flag, so the mount point is at least put into read only mode. This usually helps to get some of the blocking handles to disappear and finally you can unmount the share.
This might not always work but has helped me numerous times so I haven’t had to reboot the client.
You can also remount the same share to the same directory again if the server is responding again. Not the best way to handle it but at least you can get the mount back if you need it.