disable cd/dvd button on linux laptop (ubuntu)

My todler is continuosly pushing the cd/dvd button and trying to destroy the tray. I know it should be possible to let her life harder, disabling the eject button. How to do that? This is ubuntu (shouldn't matter) linux. See also the this related question.

And the same one as this one, but on windows

EDIT: this is Hardy


You might want to try this out...

http://www.poweradded.net/2009/09/cddvd-tray-lockunlock-under-linux.html


At the command line:

eject -i 1

To return to normal:

eject -i 0

Or you can software eject it using:

eject

In all cases, you can add a device name if you have more than one ejectable device.

Apparently, this doesn't work with all versions of eject. If it doesn't with yours, you can bypass eject completely and do it the "hard" way:

echo 1 | sudo tee /proc/sys/dev/cdrom/lock

Ubuntu's default automounter doesn't lock the CD/DVD try when it mounts an inserted disc. But if you mount the disc manually (say, with sudo), the tray should lock and stay locked until you dismount the disc.

So this process would accomplish what you want, without disabling other functionality, and you could even script it for quick access:

  1. Insert a disc,
  2. Run sudo umount /media/cdrom, then
  3. Run sudo mount /dev/cdrom /media/cdrom

Obviously, replace those paths and devices with ones your system uses.


A user left a comment on another question. The comment should have been a separate answer. I'm writing his suggestion here, since it might work for somebody (it doesn't in Hardy Haron) and might be more convenient than installing the code from my accepted question.

To lock:

sudo bash -c 'echo 1 > /proc/sys/dev/cdrom/lock'

To unlock:

sudo bash -c 'echo 0 > /proc/sys/dev/cdrom/lock'

Of course small shell scripts, possibly linked from the panel would be used.


You might want to try out cdctl. It's available here: http://cdctl.sourceforge.net/. This switch will accomplish what you want.

       -oS, --lockdoor=S
          Locks the eject button so the disc cannot be manually ejected.  Requires  kernel  ver‐
          sion 2.2.4 or newer.  Set S to 0 to unlock the drive, and to 1 to lock it.

I've used this for the last 10 years on Fedora, RHEL, CentOS but the package is available as a tarball and should be compilable on Ubuntu. NOTE: The package hasn't been updated in a while but it works fine. There's a patch available on gentoo's site that fixes a small issue so that it can be compiled with more recent kernels. The patch is available here:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-misc/cdctl/files/cdctl-0.15-cdc_ioctls.patch?revision=1.1

Once you've installed it you can use the command to lock the cd tray:

cdctl -o1

To unlock the tray:

cdctl -o0

I've recently repackaged cdctl for use on Debian/Ubuntu 12.10. It's available here, http://www.lamolabs.org/blog/wp-content/uploads/2011/01/cdctl_0.15-1.lamolabs.1_amd64.deb