linux umount 時出現device is busy 的處理方法--fuser

當任何目錄有 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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章