常常我们对某个设备读写后,要卸载掉该设备,然后常常在这个时候会出现以下头疼的提示,这通常是因为有进程在对该设备进行读写操作,而该进程还在活跃状态
比如我将设备/dev/sde1 挂载在usb ,并且进入该目录,然后打开一个新的tty并且卸载该目录设备,就会有如下提示
umount: /mnt/lst/usb: device is busy.
(In some cases useful info about processes that usethe device is found by lsof(8) or fuser(1))
如果是有经验的人,会想到刚刚是否有开了别的程序,比如用winscp访问了该文件夹,又或者某个用户正在改设备挂载的目录下而没有退出等等。退出相应设备挂载目录后,就可以正常卸载了。这样比较安全。然后有时候确实不知道是什么进程占用了,那该怎么办呢。这时候要用到一个linux下的工具叫fuser
root@moyue-virtual-machine:/mnt/lst# fuser --help
fuser: Invalid option --help
Usage: fuser [-fMuv] [-a|-s] [-4|-6] [-c|-m|-n SPACE] [-k [-i] [-SIGNAL]] NAME...
fuser -l
fuser -V
Show which processes use the named files, sockets, or filesystems.
-a,--all display unused files too
-i,--interactive ask before killing (ignored without