Unmounting the unresponsive CD/DVD/Floppy drive
The newbie states that when he pushes the Eject button on the DVD drive of a server running a certain Redmond-based operating system, it will eject immediately. He then complains that, in most enterprise Linux servers, if a process is running in that directory, then the ejection won't happen.
For too long as a Linux administrator, I would reboot the machine and get my disk on the bounce if I couldn't figure out what was running and why it wouldn't release the DVD drive. But this is ineffective. Here's how you find the process that holds your DVD drive and eject it to your heart's content:
First, simulate it. Stick a disk in your DVD drive, open up a terminal, and mount the DVD drive:
while [ 1 ]; do echo "All your drives are belong to us!"; sleep 30; done
Now open up a second terminal and try to eject the DVD drive:
You'll get a message like:
umount: /media/cdrom: device is busy
Before you free it, let's find out who is using it.
You see the process was running and, indeed, it is our fault we can not eject the disk. Now, if you are root, you can exercise your godlike powers and kill processes:
fuser -k /media/cdrom
Boom! Just like that, freedom. Now solemnly unmount the drive:
fuser is good.
I have just found one case where fuser will not be of any help. If the directory is a mount point the system will refuse to allow any modifications to it but fuser will not report any process as the culprit so keep that in mind. - 17 May 2010.
Source: 10 Essentials Tricks for admin