target is busyやdevice is busyをumountする方法

umountコマンドを実行すると、target is busyやdevice is busyと出てマウントを解除できない場合があります。
これはなんらかのプロセスによってデバイスが使用されている場合に発生するエラーです。

# umount /mnt
umount: /mnt: target is busy.
  (In some cases useful info about processes that use
   the device is found by lsof(8) or fuser(1))
# umount /mnt
umount: /mnt: device is busy
In some cases useful info about processes that use the device is found by lsof or fuser
場合によっては、デバイスを使用するプロセスに関する有用な情報がlsofまたはfuserにあります。

lsofやfuserを使用すると、デバイスを使用中のプロセスがわかります。

# lsof /mnt
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
updatedb 29720 root  cwd    DIR   8,33    12288 88096885 /mnt/……
updatedb 29720 root    8r   DIR   8,33     4096        2 /mnt
# fuser -v /mnt
      USER PID ACCESS COMMAND
/mnt: root 29720 ..c.. updatedb

lsofやfuserでプロセスが分かれば、PIDに該当するプロセスをkillコマンドで停止します。
この例だとPIDは29720です。

# kill 29720

lsofやfuserがインストールされていない場合はyumなどでインストールできます。

yum -y install lsof

fuserはpsmiscパッケージに含まれます。

yum -y install psmisc

fuserの-kオプションでは、デバイスを使用中のプロセスを強制的に停止することができます。

# fuser -k /mnt

強制的にumountする

強制的にumountするには、「-f」オプションを付けます
-f : 強制的にアンマウントします

# umount -f /mnt

busyを無視して強制的にumountするには、「-l」オプションを付けます
-l : 現在のファイルシステムから指定されたファイルシステムを切り離し、ファイルシステムへの全ての参照がなくなった際に動作を行います

# umount -l /mnt

関連記事

スポンサーリンク

write-tree

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る