红联Linux门户
Linux帮助

umount不行时这样做

发布时间:2007-10-14 21:10:01来源:红联作者:cights
前言:今天网站的mount点又掉了,按平时的把apache关掉再把mount点umount再去打开apache再mount上,结果在umount的时候就是提示:

umount: /mnt/storage_pic: device is busy
umount: /mnt/storage_pic: device is busy

后来又把共享的点关闭,断开用户和任务连接,再umount同样没得成功.

后来通过查阅Google,可以用以下的办法.

linux下的磁盘分区通过挂载(mount)的方式连到一个目录下,打开此目录就可以看到磁盘分区中的内容了。与挂载相反的操作是umount,他将磁盘分区与目录的关联关系解除。

但有时候umount时会报错误,例如
# umount /usr/local/
umount: /usr/local: device is busy

这说明还有某个程序正在是用此目录,为了保证程序的运行,默认情况下umount不能卸载。但是umount又没有说究竟哪个程序在使用,觉得这也算是设计的一个缺陷。

幸好有个程序叫fuser,man fuser的介绍是:
fuser - identify processes using files or sockets

fuser后加需要查的资源就可以知道有哪些进程正在使用了,例如:
#fuser -m /
/: 8892r 8916r 8932r 8959r 8992rc 8996rc 8997rc 8999rc 9006rc 9007rc 9010rc 9013r 9015rc 9025r 9029r 9033rc 9035r 9039rc 9058rc 9107rc 9109rc 9126rc 9130r 9366r 9375r 9439r

接下来需要做的就是将相关进程停掉,再umount即可。

PS: 多谢pnt的提醒,原来umount 还有一个-l选项,作用是当需卸载文件系统的引用不繁忙时直接卸载:

umount -l Lazy unmount. Detach the filesystem from the filesystem hierar-
chy now, and cleanup all references to the filesystem as soon as
it is not busy anymore. (Requires kernel 2.4.11 or later.)
文章评论

共有 0 条评论