device is busy時怎麼辦 linux下的磁碟分割通過掛載(mount)的方式連到一個目錄下,開啟此目錄就可以看到磁碟分割中的內容了。與掛載相反的操作是umount,他將磁碟分割與目錄的關聯關係解除。 但有時候umount時會報錯誤,例如 Code: # umount /usr/local/ umount: /usr/local: device is busy 這說明還有某個程式正在是用此目錄,為了保證程式的運行,預設情況下umount不能卸載。但是umount又沒有說究竟哪個程式在使用,覺得這也算是設計的一個缺陷。 幸好有個程式叫fuser,man fuser的介紹是: Code: fuser - identify processes using files or sockets fuser後加需要查的資源就可以知道有哪些進程正在使用了,例如: Code: #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選項,作用是當需卸載檔案系統的引用不繁忙時直接卸載: Code: 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.)