LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

eject

removable media ejection utility

TLDR

Open the tray of whichever device is the default
$ eject
copy
Eject a named device
$ eject [/dev/sr0]
copy
Eject by mount point instead
$ eject [/media/cdrom]
copy
Show which device would be used by default
$ eject --default
copy
Close the tray again
$ eject --trayclose [/dev/sr0]
copy
Toggle the tray open or closed
$ eject --traytoggle [/dev/sr0]
copy
Show what would happen without doing it
$ eject --noop [/dev/sr0]
copy
Eject even if the device is busy
$ eject --force [/dev/sr0]
copy
Treat the device as a tape drive
$ eject --tape [/dev/st0]
copy
Set the drive's read speed
$ eject --cdspeed [8] [/dev/sr0]
copy
List the speeds the drive supports
$ eject --listspeed [/dev/sr0]
copy
Lock the physical eject button
$ eject --manualeject on [/dev/sr0]
copy

SYNOPSIS

eject [options] [device|mountpoint]

DESCRIPTION

eject ejects removable media such as CDs, DVDs, floppy disks, and tape drives. It can also control the tray mechanism and lock/unlock devices.The default order for device types is cd-rom, scsi, floppy, then tape.

PARAMETERS

-d, --default

Display the default device
-T, --traytoggle
Toggle tray open/closed state
-r, --cdrom
Eject using CD-ROM method
-f, --floppy
Eject using floppy method
-q, --tape
Eject using tape method
-i, --manualeject on|off
Control whether physical button works
-t, --trayclose
Close the tray
-a, --auto on|off
Enable or disable the drive's auto-eject mode
-m, --no-unmount
Do not unmount the device even if it is mounted
-M, --no-partitions-unmount
Do not unmount other partitions on the same device
-n, --noop
Show which device would be used without ejecting it
-p, --proc
Use /proc/mounts instead of /etc/mtab
-s, --scsi
Eject using SCSI commands
-x, --cdspeed speed
Set the CD-ROM drive speed (0 selects the maximum)
-X, --listspeed
List the speeds the drive supports
-v, --verbose
Print more information about what is happening

INSTALL

sudo apt install eject
copy
sudo apk add util-linux-misc
copy
nix profile install nixpkgs#eject
copy

CAVEATS

eject unmounts the device (and, by default, all other partitions on it) before ejecting; use -m to skip that. Ejection fails if a process still holds a file open on the mounted filesystem. Many laptop and USB optical drives ignore the tray commands, and -x speed control depends on drive firmware. Part of the util-linux package.

SEE ALSO

mount(8), umount(8), lsblk(8), udisksctl(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid