eject allows ejecting a removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) using the software. You can also control some multi-disc CD-ROM changers, the auto-eject feature (supported by some devices) and also close the disc tray of some CD-ROM drives. The methods of ejecting depend on the device type, whether it is a CD-ROM, SCSI device, removable floppy, or tape. The default action of eject is that it tries all four methods in order until it achieves success. The device is unmounted, if it is mounted, before ejecting.
Options of the eject command:
- -h or –help : Display help for available commands.
- -v or –verbose : Log out more information about the command’s execution.
- -d or –default : List default device name.
- -a on|1|off|0 or –auto on|1|off|0 : Control auto-eject mode supported by some devices with this command. Enable this to auto-eject when the device is closed.
eject -a on
- -c or –changerslot : Select a CD slot from an ATAPI/IDE CD-ROM changer. You need Linux 2.0+ to use this feature. You have to make sure that the CD slot is not already in use. The first available slot is referred to as 0.
eject -c 0
- -t or –trayclose : Use this command to give the drive a tray close command.
Note: Hardware support for this feature is limited.
- -T or –traytoggle : This option gives the tray close command, if the slot is open, or an eject command, if the slot is closed.
Note: Hardware support for this command is limited, as it makes use of the above -t command.
- -x or –cdspeed : Give a CD-ROM select speed command to the drive with this option. An argument is a number, which indicates the desired speed (e.g. 3 for 3X speed), or 0 for maximum data rate. Device support for this command is limited, and you can only specify speeds that the drive is capable of. The option is cleared everytime the media is changed. This option can also be used with -c or -t command.
eject -x 0
- -X or –listspeed : Display a list of available speeds from the CD-ROM drive using this option. You can use the speeds listed as an argument in the -x option. You need Linux 2.6.13+ to work with this option. On older versions, it will only report the maximum speed. Also, some drives may not correctly report the speed, thus this option does not work with them.
- -n or –noop : Display the selected device, but perform no action using this option.
- -r or –cdrom : Specify that the drive should be ejected using a CDROM eject command using this option.
- -s or –scsi : Specify that the drive should be ejected using SCSI commands using this option.
- -f or –floppy : Specify that the drive should be ejected using a removable floppy disk eject command using this option.
- -q or –tape : Specify that the drive should be ejected using a tape drive offline command using this option.
- -p or –proc : Use /proc/mounts instead /etc/mtab with this command. It also passes the -n option to umount.
- -m or –no-unmount : Allow eject to work with device drivers which autonomously mount removable media and therefore must be always mounted. The option tells eject not to try to unmount the given device, even if it is mounted according to /proc/mounts or /etc/mtab.
- -V or –version : Log the version number to console and exit.
Exit Status: On successful operation, 0 is returned, and on failed operation, 1 is returned.
- cc command in Linux with Examples
- more command in Linux with Examples
- which command in Linux with examples
- yes command in Linux with Examples
- atq command in linux with examples
- for command in Linux with Examples
- rm command in Linux with examples
- Cat command in Linux with examples
- cd command in Linux with Examples
- fmt command in Linux with examples
- cut command in Linux with examples
- cmp Command in Linux with examples
- gdb command in Linux with examples
- dc command in Linux with examples
- cp command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.