星期二, 十一月 18, 2008

Linux: umount 時 出現 "Device is busy" 的解法

當任何目錄有 mount, 然後有程式 使用/掛 在那個目錄上的話, 就沒有辦法 umount 掉, 於 umount 時會出現 Device is busy 的訊息.

要怎麼找出是哪個程式掛在那個目錄上? 然後去把那個程式砍掉呢?

使用 fuser 的指令

那要怎麼找出是哪個程式掛在那個目錄上, 可以使用 fuser - identify processes using files or sockets

假設現在 mount 起來的目錄是 /media/share

  • 查詢: fuser -m /media/share
  • 顯示: /media/share: 25023c

就代表是 process 25023(pid) 有使用到此目錄, 後面 c 代表的意思可參考下述:

  • c: current directory.
  • e: executable being run.
  • f: open file. f is omitted in default display mode.
  • F: open file for writing. F is omitted in default display mode.
  • r: root directory.
  • m: mmap'ed file or shared library.

要把這個資源釋放的話, 可以有下述做法:

  • kill -9 25023 # ps aux | grep 25023 應該就會看到它
  • fuser -m -v -i -k /media/share # 會問你是不是要把 25023 這個 kill 掉, 選 y 就會 kill 掉
    訊息如下:
                  USER      PID   ACCESS COMMAND
    /meida/share: root      25023 ..c..  bash
    Kill process 25023 ? (y/N) y

相關網頁

相關標籤

this is comment icon 感謝... [回覆]

不錯不錯,學到一招。

之前要去除掛載不行都等一段時間再重新輸入一次...囧

Comment by zhua (11/18/2008 15:16)

this is comment icon [回覆]

vi /etc/mtab 把不要的拿掉
/etc/init.d/autofs restart
即可 :)

忘記是那位長輩的 blog 看來的。

Comment by Sean (11/18/2008 23:42)

this is comment icon 回 Sean [回覆]

感謝提供.. Orz..

Comment by Tsung (11/19/2008 01:21)

this is comment icon [回覆]

不錯的方法,有解決問題,感謝分享!

Comment by jt (09/18/2009 12:59)

this is comment icon [回覆]

完來是這樣 感謝!!

Comment by adf (02/20/2010 23:59)
Add this page to del.icio.us

發表迴響

標題

內容 (限制 1000 字)

暱稱

電子郵件

個人網頁


 authimage


PS: 若無法留言, 請先確認是否有打開 JavaScript, 造成您的困擾, 實在萬分對不起 Orz...(如果無法留言, 勞煩可以發信給我好嗎? 謝謝.)
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~