Linux CD / DVD Locked and Drive Is Not Opening / Ejecting CD

by Vivek Gite [Last updated: June 26, 2008]

Q. I've Ubuntu Linux Installed on HP Desktop system. When I press the eject button my DVD / CD nothing happens. Linux is not ejecting my CD and I had to reboot my computer to just get CD out of drive. How do I fix this issue?

A. You don't have to reboot the system to just eject CD / DVD from drive. Sometime Linux locks down your CD / DVD if a process reading / accessing file / directory on that DVD / CD.

Getting Your CD/DVD Out Of Drive

Simply right click on CD / DVD icon and select Eject / Unmount option. Press eject button to get the cd/dvd out. If this failed, try following method to eject the cd:

Find Out CD/DVD drive mount location

Run df or mount command to find out location, enter the following at terminal / shell prompt:
$ df
Sample output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              92G   22G   66G  25% /
varrun               1013M  140K 1013M   1% /var/run
varlock              1013M     0 1013M   0% /var/lock
udev                 1013M   88K 1013M   1% /dev
devshm               1013M     0 1013M   0% /dev/shm
lrm                  1013M   34M  979M   4% /lib/modules/2.6.22-14-generic/volatile
/dev/sda1              98G   19G   79G  20% /media/sda1
/dev/sda5             274G  185G   89G  68% /share
/dev/scd0             3.5G  3.5G     0 100% /media/cdrom0

Your CD / DVD device name is /dev/scd0 and mounted under /media/cdrom0. Now issue the following command as root:
$ sudo fuser -km /media/cdrom0
OR
# fuser -km /media/cdrom0
Now you should able to eject CD / DVD.
Related: See How to forcefully remove unmount a Linux disk partition / device using lsof and fuser command.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 2 comments… read them below or add one }

1 mircea 06.26.08 at 5:35 pm

I think there is an alternative to this method. The “eject” command. You can use it from a terminal or simpler from the “Run application” dialog (e.g. Alt+F2 in Gnome).

2 Jeff Schroeder 06.29.08 at 7:45 pm

You might also try disallowing the kernel from locking the cdrom. Sometimes a rogue process will hold onto the drive for no real reason. This way is often much cleaner than killing the process.

# Temporarily unlock the cdrom
echo 0 > /proc/sys/dev/cdrom/lock

# Permanently unlock the cdrom
echo “sys.dev.cdrom.lock=0″ >> /etc/sysctl.conf

Can you switch your blog to reCaptcha? It helps to translate old books and is a better captcha than yours.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , ,

Previous post: Restart / Update init Configuration File /etc/inittab After Changes Without Rebooting Server

Next post: UNIX / Linux Command To Check Existing Groups and Users