
问题描述
Linux下挂载后的分区或者磁盘某些时候需要umount的时候出现类似“umount: /mnt: target is busy.”等字样,或者“umount: /xxx: device is busy.”。
[root@ecs-prod-my57-fserp-ro ~]# umount /mydump/
umount: /mydump: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
问题原因
该报错通常是由于待卸载磁盘正在使用,导致无法直接卸载。需要将当前使用数据盘的进程杀掉,才能卸载。
解决办法
方法一、 使用fuser命令处理
- 安装fuser命令
yum install psmisc
- 查看在使用的进程
[root@ecs-prod-my57-fserp-ro ~]# fuser -mv /mydump/
USER PID ACCESS COMMAND
/mydump: root kernel mount /mydump
root 21765 ..c.. screen
root 21766 ..c.. bash
root 21780 ..c.. bash
- 杀死占用的进程
[root@ecs-prod-my57-fserp-ro ~]# fuser -kv /mydump/
USER PID ACCESS COMMAND
/mydump: root kernel mount /mydump
root 21765 ..c.. screen
root 21766 ..c.. bash
root 21780 ..c.. bash
- 再次查看
[root@ecs-prod-my57-fserp-ro ~]# fuser -mv /mydump/
USER PID ACCESS COMMAND
/mydump: root kernel mount /mydump
- 确认无进程使用后,使用卸载命令
umount /mydump
方法二、通过lsof命令处理
- 安装lsfo命令
yum install lsof
- 查看使用硬盘进程
[root@ecs-prod-my57-fserp-ro ~]# lsof /mydump/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
screen 21765 root cwd DIR 253,32 23 64 /mydump
bash 21766 root cwd DIR 253,32 23 64 /mydump
bash 21780 root cwd DIR 253,32 23 64 /mydump
- 杀死进程
kill 21765;
kill 21766;
kill 21780;
- 卸载硬盘
umount /mydump