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?