Press "Enter" to skip to content

Linux umount卸载无响应的NFS文件系统

当NFS Client无法访问NFS Server的时候,在Client上df -h操作就会卡住.这个时候就需要将挂载的NFS卸载掉,在不知道挂载点的情况下,可以使用nfsstat -m命令来查看.
nfsstat未安装的话可以配置好yum源直接yum安装:yum install -y nfsstat
[root@test ~]# nfsstat -m
/home/app/test from 1.2.3.4:/home/app
Flags: rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=1.2.3.4,mountvers=3,mountport=4001,mountproto=udp,local_lock=none,addr=1.2.3.4
结果发现umount -f和fuser -k都卸载不掉,报错:umount2: Device or resource busy.
最后查询得知,可以用umount -l直接卸载:umount -l /home/app/test

[root@test ~]# umount --help

Usage:
umount [-hV]
umount -a [options]
umount [options] <source> | <directory>

Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoins for the given device
in the current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount.<type> helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, and cleanup all later
-O, --test-opts <list> limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only In case unmounting fails, try to remount read-only
-t, --types <list> limit the set of filesystem types
-v, --verbose say what is being done

-h, --help display this help and exit
-V, --version output version information and exit

For more details see umount(8).

选项–l并不是马上umount,而是在该目录空闲后再umount.

Be First to Comment

发表评论

电子邮件地址不会被公开。 必填项已用*标注