I recently upgraded my Dell Inspiron 5558 to Ubuntu 18.04. Ever since the upgrade, the DVD drive keeps opening automatically at random times. How do I resolve this issue?

1 Answer 1


Does Ubuntu 18.04 have the setcd package available? If it is, install it and then run:

sudo setcd -s /dev/sr0

It should output something like this:

  Auto close tray:     cleared
  Auto open tray:      cleared
  Use O_NONBLOCK flag: set
  Lock tray:           set
  Check CD type:       cleared

If "Auto open tray" says "set" instead, running sudo setcd -o0 /dev/sr0 should fix your problem until the next reboot.

The root cause might be a tool in your desktop environment that can be used to mount removable disks. It polls the DVD drive every now and then. If the "Auto open tray" is set, the tray will open when the poll is done and the tool stops accessing the drive.

If disabling the "auto open" feature helps you, you might want to disable the "auto close" feature too, as it might try and close the drive just when you're about to place a disc on the tray. I had this problem with my system back in Debian 7 or so with KDE.

Ubuntu 18.04 has systemd, so probably the best way to make these settings persistent is to create a service file to run the necessary setcd command at boot time.

So, create a file in /etc/systemd/system with a descriptive name and a .service suffix. For example, let's call it /etc/systemd/system/dvd-stop-open.service. The contents of the file should be:

Description=Disable DVD auto-open

ExecStart=/usr/bin/setcd -o0 /dev/sr0


Once the service file is created, enable the service:

sudo systemctl enable dvd-stop-open.service

Test by starting the service and verifying that the Active: field in service status says active (exited):

sudo systemctl start dvd-stop-open.service
systemctl status dvd-stop-open.service

Or alternatively, you can avoid changing systemd by simply inserting a '0' into /proc/sys/dev/cdrom/autoeject

Pick one:

Using rc.local:

echo 0 > /proc/sys/dev/cdrom/autoeject

Using /etc/crontab:

@reboot root    echo 0 > /proc/sys/dev/cdrom/autoeject

Or as a one-time, non-persistant across boots, command line use sudo:

echo 0 | sudo tee /proc/sys/dev/cdrom/autoeject

This will take effect immediately. No sysctl or service file restart needed...

  • Thanks, this seems to have solved the issue. How do I make these settings stick on boot? Jul 27, 2018 at 4:40
  • Answer updated with instructions for creating a simple systemd service file.
    – telcoM
    Jul 27, 2018 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.