While physical optical drives are becoming rare on modern laptops, they are still widely used in older enterprise desktop servers and media ripping machines running Ubuntu Linux. Occasionally, a CD or DVD will become physically jammed inside the drive, and pressing the physical hardware eject button on the front of the disc tray will do absolutely nothing.
Before you resort to using a paperclip in the manual emergency release hole, you can often force the drive to eject by sending a direct software command through the Ubuntu terminal.
How to Force Eject the Drive
Ubuntu includes a dedicated utility specifically designed to handle optical drives, appropriately named eject. Sending a software eject command bypasses the physical hardware button, which is often disabled by the operating system if the drive is currently mounted and active.
- Open your Ubuntu terminal (or log in via SSH if you are managing a headless server).
- Type the following command and press Enter:
eject
In most standard single-drive configurations, this simple command is enough. The operating system will automatically unmount the disc and physically open the tray.
How to Specify a Specific Drive (cdrom)
If the generic command fails, or if you have multiple optical drives installed, you need to explicitly tell the operating system which hardware device to eject. Most CD/DVD drives are mapped to /dev/cdrom.
- Force the specific device to eject by running:
eject /dev/cdrom
How to Eject if the Drive is Locked
If the terminal returns an error stating that the device is “busy” or “in use”, it means a background process is currently reading data from the disc, locking the tray shut. You must unmount the drive forcefully before you can eject it.
- Unmount the drive first by typing:
sudo umount /dev/cdrom - Once it successfully unmounts, run the eject command again:
eject /dev/cdrom
If the tray still refuses to open after successfully unmounting the software, the issue is a mechanical jam within the drive mechanism, and you will need to use the physical emergency release hole.