Preventing accidental DVD eject

From ThinkWiki
Jump to: navigation, search

On selected ThinkPads the Optical drive eject button is located on the curved area of the bezel. As an effect, I found it almost impossible to move the ThinkPad without accidentally touching the button and ejecting the drive.

The good thing is that I have very little use for an Optical drive these days, So my workaround to this issue is to software lock the drive on boot, and have 2 scripts to lock/unlock the drive when needed.

To lock the drive on boot, simply add the following line to /etc/rc.local

/usr/bin/eject -i 1 /dev/sr0

Then I created two scripts, /usr/bin/lock and /usr/bin/unlock to quickly lock the drive or unlock+eject when needed.


/usr/bin/eject -i 1 /dev/sr0


/usr/bin/eject -i 0 /dev/sr0
/usr/bin/eject /dev/sr0

Lastly, the scripts need to be owned by root, set executable and SUID root so you can run them as a regular user without having to resort to sudo.

chown root:root /usr/bin/lock /usr/bin/unlock
chmod 6555 /usr/bin/lock /usr/bin/unlock 

Effected ThinkPads