禁用和启用 CD-ROM

Vik*_*hav 4 cd

出于安全原因(因此没有人可以将数据从计算机复制到 CD-ROM,或从 CD-ROM 复制到计算机),我必须在我拥有的所有 Ubuntu 系统上禁用 CD-ROM 驱动器。

我估计我有近 400-500 台 Ubuntu 机器。

如何禁用 CD-ROM 驱动器,然后再次启用它们。

如果可能,我希望命令能够同时启用和禁用 CD-ROM 驱动器。

Rin*_*ind 6

锁定驱动器:

eject -i 1
Run Code Online (Sandbox Code Playgroud)

解锁驱动器:

eject -i 0
Run Code Online (Sandbox Code Playgroud)

来自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.
Run Code Online (Sandbox Code Playgroud)

请注意,此命令可供系统上的用户使用,因此您可能还想创建一个alias来覆盖正常弹出。并非所有版本的弹出都支持锁定(Ubuntu 15.04+ 中的版本支持锁定;低于此我不确定)。


该命令的作用是...

echo 1 | sudo tee /proc/sys/dev/cdrom/lock
echo 0 | sudo tee /proc/sys/dev/cdrom/lock
Run Code Online (Sandbox Code Playgroud)

所以你也可以使用它。


这些也是您可以使用的名为cdctl的 3rd 方脚本。


15:04(我拥有的最旧的 Ubuntu):

$ eject --version
eject version 2.1.5 by Jeff Tranter (tranter@pobox.com)
$ eject -i 1
CD-Drive may NOT be ejected with device button
$ eject -i 0
CD-Drive may be ejected with device button
Run Code Online (Sandbox Code Playgroud)