Trying to unmount the CDROM gives "...device busy". I know that this means that the CDROM directory is being accessed from one of my shells and that I should cd away from there, but which one is it?
This is very annonying when you have a lot of terminal windows open or when the process that originally accessed the CDROM unexpectedly died. What we want to do in this case is to avoid having to close or check all the windows. The elegant (and fast!) way to do it is using the fuser command:
fuser /mnt/cdrom/i386/ /mnt/cdrom/i386/: 3170 3233 3467 |
ps -ef | grep 3170 ps -ef | grep 3233 |
kill -9 3170 3233 3467 |
If you have the lsof command (list open files) that could be
useful too, especially in the more tricky case when you have quited every
CD directory that has been accessed and still you cannot unmount the CD.
Suppose for instance that you changed directory to the mount point of the
CD-ROM (something like cd /mnt/cdrom) and launched an application
from there (like xmixer &). Now because the initial working
directory of xmixer was the CD mount point, this last directory
is perceived as being in use by the umount command, and the message
will be
umount: /mnt/cdrom: device is busy.
After you have cd-ed away from all CD-ROM directories, instead of wondering
why on earth you cannot unmount the CD, just issue:
lsof | grep cdrom xmixer 2192 fdonea cwd DIR 22,64 6144 79872 /mnt/cdrom |
Return to : Unix System Administration Hints and Tips