eject Command

The eject command safely unmounts and ejects removable media such as CD/DVD drives, floppy disks, and other removable storage devices from the system.

Syntax

eject [OPTIONS] [DEVICE]

Description

The eject command allows users to safely remove removable media by first unmounting the filesystem and then ejecting the physical media. It works with various types of removable devices.

Key features:

  • Safely unmounts filesystems before ejection
  • Works with CD/DVD drives, floppy disks, and USB devices
  • Can toggle CD/DVD trays (open/close)
  • Supports various device types and interfaces
  • Provides status information about devices

Common Options

Option Description
-t Toggle tray (close if open, open if closed)
-T Close tray only
-s Enable SCSI commands
-r Eject CD-ROM using CDROM eject command
-n Don't unmount device before ejecting
-v Verbose output
-d Display default device
-a on|off Turn auto-eject on or off

Examples

Eject default CD/DVD drive

eject

Ejects the default removable media device

Eject specific device

eject /dev/cdrom

Ejects the CD/DVD drive at /dev/cdrom

Eject by mount point

eject /media/cdrom

Ejects device mounted at /media/cdrom

Toggle CD/DVD tray

eject -t /dev/cdrom

Toggles the CD/DVD tray (opens if closed, closes if open)

Close CD/DVD tray

eject -T /dev/cdrom

Closes the CD/DVD tray

Verbose ejection

eject -v /dev/cdrom

Ejects with verbose output showing the process

Display default device

eject -d

Shows the default eject device

Eject without unmounting

eject -n /dev/cdrom

Ejects without unmounting (use with caution)

Enable auto-eject

eject -a on /dev/cdrom

Enables automatic ejection when media is finished

Disable auto-eject

eject -a off /dev/cdrom

Disables automatic ejection

See also