Troubleshooting the "device is busy" Error Attempting to umount a Disk

本文介绍了如何使用fuser命令来确定哪些文件或目录在一个文件系统中被占用,以及哪些进程和用户正在使用它们。此外,还介绍了如何利用该命令卸载繁忙的文件系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

by Jeff Hunter, Sr. Database Administrator


Before attempting to dismount a filesystem, it must be inactive. If "any user" has one of the filesystem's directories as their current directory or has any file within the filesystem open, you will receive an error message, like the one below, when attempting to unmount the filesystem:

  # umount /dev/dsk/c0t2d0s7
umount: /dev/dsk/c0t2d0s7: device is busy
Well, the fuser command to the rescue. The fuser command may be used to determine which files or directories within a filesystem are currently in use and to identify the processes and users that are using them. fuser is available on all major flavors of UNIX with the exception of Digital UNIX.

The fuser command can take two types of arguments:

  • normal filename: You can pass a normal filename or directory to the fuser command. In this case, it reports on that file or directory alone.

  • special disk: You can also pass in a special disk name as an argument to fuser. In this case, it reports on all files and directories within the corresponding filesystem.

You can use the -u option to the fuser statement to display the user ID's as well as PID's in its output.

Lets look at a few examples. The following command will display all processes and their associated users that are using files/directories on a specified disk on a Sun Solaris system:

  # fuser -u /dev/dsk/c0t2d0s7
/dev/dsk/c0t2d0s7: 1313co(oracle) 1223c(root)
In the above example, there are two processes using the filesystem mounted on /dev/dsk/c0t2d0s7 (which in my example is the /db filesystem) at the time of running the command. The User ID's are root, and oracle. The c being printed after the PIDs indicate that this is their current directory.

You can use the -k option to kill all processes using the specified file or filesystem. In the following example, the UNIX PIDs 1313 and 1223 will be killed:

  # fuser -k /dev/dsk/c0t2d0s7
/dev/dsk/c0t2d0s7: 1313co 1223c
In Linux, you can use the -m option to allow you to specify the filesystem by name. On Solaris and IRIX, the -c option performs the same task. 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值