Return to General UNIX Home Page.


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

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:

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.



Last modified on: Saturday, 18-Sep-2010 18:21:05 EDT
Page Count: 218789