博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
强制Umount NFS终极手法
阅读量:4197 次
发布时间:2019-05-26

本文共 2094 字,大约阅读时间需要 6 分钟。

 当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/

http://tonnyxs.blog.163.com/blog/static/27937985201102202028695/

转载地址:http://bsuli.baihongyu.com/

你可能感兴趣的文章
编程语录
查看>>
关于指导思想
查看>>
2011-1-2-------------Mage::getStoreConfig-----函数分析!!
查看>>
2011-1-2----------mage:getModuleDir函数的分析!!--------得到模块的地址
查看>>
2010-1-3------mage_core_model_config------------construct过程----------------个人分析
查看>>
2011-1-3----mage_core_model_config---------init()方法加载过程---个人分析
查看>>
JDK里的设计模式
查看>>
2011-1-4-----核心模型---mage_core_model_cache---construct方法--个人分析
查看>>
2011-1-4----mage_core_model_layout--construct方法--个人分析
查看>>
学做程序经理--转
查看>>
国外主流PHP框架比较
查看>>
css中cursor属性详解
查看>>
JDK里的设计模式
查看>>
相关产品设置插件
查看>>
深入理解Magento – 第一章 – Magento强大的配置系统
查看>>
深入理解Magento – 第二章 – Magento请求分发与控制器
查看>>
深入理解Magento – 第三章 – Magento的布局(Layout),块(Block)和模板(Template).doc
查看>>
joomla
查看>>
magento ----使用magento内部机制建立数据库表
查看>>
深入理解Magento – 第四章 – 模型和ORM基础.doc
查看>>