Linux查看目录被进程所占用lsof命令
之前将一块硬盘挂载到某个目录下,但是现在我想卸载掉这块硬盘,无论如何都umount不了,有些同学可能说需要加上 -f 参数强制卸载,理论上是可以的,但是在我这里依然不起作用,比如:
[root@:vg_adn_clickhouseTest_1ubuntu:: ~]#umount -f /data2
umount: /data2: target is busy.
我是把一块2T的硬盘挂载到/data2目录下了,可是现在就是卸载不了,说是设备忙,仔细分析一下可以得出应该是某些应用程序的进程占用了这块分区/data2 。应用程序一直在跑着,所以我们无法卸载这块硬盘。解决的方法就是找出哪个进程在占用这块硬盘。那我们知道一块硬盘一般上都是关联至某一个目录下的。所以我们就去找这个目录被哪些进程所占用。使用命令 lsof 即可
命令:
[root@:vg_adn_clickhouseTest_2ubuntu:172.31.19.193 ~]#lsof /data2
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
clickhous 31721 clickhouse 7wW REG 253,0 59 45088774 /data2/clickhouse/status
[root@:vg_adn_clickhouseTest_2ubuntu:172.31.19.193 ~]#kill -9 31721
[root@:vg_adn_clickhouseTest_2ubuntu:172.31.19.193 ~]#service clickhouse-server status
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: signal) since Wed 2019-01-16 10:51:32 UTC; 11s ago
Process: 31721 ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml (code=killed, signal=KILL)
Process: 31715 ExecStartPre=/bin/chown clickhouse:clickhouse -R /etc/clickhouse-server (code=exited, status=0/SUCCESS)
Process: 31713 ExecStartPre=/usr/bin/chown clickhouse:clickhouse -R /etc/clickhouse-server (code=exited, status=0/SUCCESS)
Main PID: 31721 (code=killed, signal=KILL)
Jan 16 10:51:32 ip-172-31-19-193 systemd[1]: clickhouse-server.service: Failed with result 'signal'.
版权申明
本文系作者 @Mrjun 原创发布在懒猪儿Blog站点。未经许可,禁止转载。
全部评论 1
大根宝
Google Chrome Windows 10我明白了[doge]