ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

强制Umount NFS终极手法

2021-04-08 14:53:55  阅读:192  来源: 互联网

标签:17 webapps upload umount NFS Umount apache home 终极


当Umount一个目录时,提示device is busy,umount加参数f,是强制执行umount,但是许多时候均不会成功。 
原理上要想umount,首先要kill正在使用这个目录的进程。*假设无法卸载的设备为/dev/sdb1 
1)运行下面命令看一下哪个用户哪个进程占用着此设备 
fuser -m -v /dev/sdb1

2)运行下面命令杀掉占用此设备的进程 
fuser -m -v -k /dev/sdb1 
或者fuser -m -v -k -i  /dev/sdb1(每杀掉一下进程会让你确认) 
3)再umount

*杀掉所有以任何形式访问文件系统 /dev/sdb1的进程: 
$fuser -km /dev/sdb1 
这个办法是一个比较粗鲁的办法,通常适用于在测试等非正式环境。比较正规的要配合ps等命令,查出使用的用户、进程、命令等,然后做出综合判断,必要时先通知(signal或口头等)用户,确认安全时才可以强制kill此进程。 
但有时fuser执行时,仍然会有报错,其实umount强制退出,可以考虑用参数l(Lazy),这个参数是比f(Force)更强大的终极命令。 

今天即使用了一下参数l,确实很强大!


Man Umount 查看f和l的参数说明如下: 
-f     Force  unmount.  This  allows  an  NFS-mounted  filesystem  to be unmounted if the NFS server is unreachable. Note: when using umount -f on an NFS filesystem, the 
              filesystem must be mounted using either the soft, or intr options (see nfs(5).  This option  will  not  force  unmount  a  <A1><AE>busy<A1><AF>  filesystem  (use  -l 
  instead). 
              (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. This option 
              allows a <A1><AE>busy<A1><AF> filesystem to be unmounted.  (Requires kernel 2.4.11 or later.) 
本次操作过程如下: 
[root@FUHOST /]# umount /home/swebapp/apache-tomcat-5.5.17/webapps/upload/ 
umount: /home/swebapp/apache-tomcat-5.5.17/webapps/upload: device is busy 
umount: /home/swebapp/apache-tomcat-5.5.17/webapps/upload: device is busy

[root@FJ-WEB-02 sbin]# umount -f /home/swebapp/apache-tomcat-5.5.17/webapps/upload/ 
umount2: 设备或资源忙 
umount: /home/swebapp/apache-tomcat-5.5.17/webapps/upload: device is busy 
umount2: 设备或资源忙 
umount: /home/swebapp/apache-tomcat-5.5.17/webapps/upload: device is busy

[root@FJ-WEB-02 sbin]# fuser -km  /home/swebapp/apache-tomcat-5.5.17/webapps/upload/ 
/home/swebapp/apache-tomcat-5.5.17/webapps/upload/: 输入/输出错误

[root@FJ-WEB-02 sbin]# fuser -um  /home/swebapp/apache-tomcat-5.5.17/webapps/upload/ 
/home/swebapp/apache-tomcat-5.5.17/webapps/upload/: 输入/输出错误

[root@FJ-WEB-02 upload]# umount -l /home/swebapp/apache-tomcat-5.5.17/webapps/upload/


标签:17,webapps,upload,umount,NFS,Umount,apache,home,终极
来源: https://blog.51cto.com/lwm666/2692380

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有