5

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?

Marco
  • 33,188
  • 10
  • 112
  • 146

1 Answers1

2

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
slm
  • 363,520
  • 117
  • 767
  • 871
  • With the patch I could compile it, but it does not work either. When I press the button the drive pops out. – Marco Jan 02 '13 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 02 '13 at 17:49
  • Curious, did you recompile on Debian? – slm Jan 02 '13 at 17:50
  • Yes, see comment under my question. I did not test interference with eject. – Marco Jan 02 '13 at 19:09
  • Not sure if you saw this Q&A, the issue with cdctl was resolved: http://unix.stackexchange.com/questions/104791/how-can-i-disable-the-button-of-my-cd-dvd-drive – slm Jan 31 '14 at 20:21
  • I tried the DISK_EJECT_REQUEST solution and `eject` works as expected. Maybe I should flag my question as a duplicate. – Marco Feb 01 '14 at 12:48
  • I voted it as a dup as well. – slm Feb 01 '14 at 14:28