Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On my laptop the eject button for the CD/DVD drive is placed in a very unfortunate position and I hit it a dozen times per day and the tray pops out. I found many solutions which seemed to work for other people:

From man eject:

-i on | 1 | off | 0

This option controls locking of the hardware eject button. When enabled, the drive will not be ejected when the button is pressed. This is useful when you are carrying a laptop in a bag or case and don't want it to eject if the button is inadvertently pressed.

This seems to be exactly what I need. eject -i on successfully returns:

CD-Drive may NOT be ejected with device button

However, hitting the device button still ejects the drive. As suggested in another answer invoking

echo 1 > /proc/sys/dev/cdrom/lock

did not help either, lock already contains 1. The information from /proc/sys/dev/cdrom/info suggests that locking is possible:

drive name:            sr0
drive speed:           24
drive # of slots:      1
Can close tray:        1
Can open tray:         1
Can lock tray:         1
Can change speed:      1
Can select disk:       0
Can read multisession: 1
Can read MCN:          1
Reports media changed: 1

The cdctl tool is not in the Debian repository and it does not build on my system.

How do I lock my drive so that hitting the hardware switch on the drive would no pop out the drive?

share|improve this question
If you mount a CD-ROM, does it lock the drive? Can you see anything different in /proc/sys/dev/cdrom? – Gilles Dec 28 '12 at 23:21
If a filesystem on the CD is mounted the locking with eject works. But not if it's not mounted or without media in drive. The contents of /proc/sys/dev/cdrom don't change. – Marco Dec 29 '12 at 0:20
What is your OS? – slm Jan 2 at 0:30
@slm Debian GNU/Linux unstable with kernel 3.5.0 – Marco Jan 2 at 17:13

1 Answer

I compiled cdctl some time ago for Fedora/CentOS. I've taken that compilation and converted to a .deb file. cdctl is the only application I've found that does a reliable job of locking/unlocking the CD/DVD eject button.

Feel free to give it a try.

Commands to lock and unlock

# locks the tray
% cdctl -o1

# unlocks the tray
% cdctl -o0
share|improve this answer
With the patch I could compile it, but it does not work either. When I press the button the drive pops out. – Marco Jan 2 at 17:11
Something must of changed with the newer kernels, it worked up to 2.6.35.14-106.fc14.x86_64 for me on Fedora 14. I tried it on my Ubuntu 12.10 system and it disables the ability of the eject command from working but not the drives button on front. I'll take a peak at the cdctl source when I get a chance. – slm Jan 2 at 17:49
Curious, did you recompile on Debian? – slm Jan 2 at 17:50
Yes, see comment under my question. I did not test interference with eject. – Marco Jan 2 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.