Wednesday, May 31, 2017

How to eject CD/DVD ROM from command line

How to eject CD/DVD ROM from command line

If you have an old laptop or an old PC, you probably have a CD or DVD rom drive, this is what people use back in the old days. But did you know that you can eject the CD/DVD drive from command line? i'm going to show you this cool trick.

On lubuntu/ubuntu there is a special command line tool for ejecting removable media, so not only CD and DVD rom but also floopy disk, tape, and zip disk. If you have one of those on your computer you can eject from command line.

The name of the command line program for ejecting removable media is called 'eject', and it's already in your system no need to install, it's already there. Here's description of the 'eject' program:
Eject allows removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) to be ejected under software control. The command can also control some multi-disc CD-ROM changers, the auto-eject feature supported by some devices, and close the disc tray of some CD-ROM drives. The device corresponding to is ejected. The name can be a device file or mount point, either a full path or with the leading "/dev", "/media" or "/mnt" omitted. If no name is specified, the default name "cdrom" is used. There are four different methods of ejecting, depending on whether the device is a CD-ROM, SCSI device, removable floppy, or tape. By default eject tries all four methods in order until it succeeds. If the device is currently mounted, it is unmounted before ejecting
How to eject CD/DVD rom drive
eject -v

By default 'eject' will look for CD/DVD rom drive on your computer and eject it, you can also specify the device that you want to eject.
eject /dev/sr0
eject /dev/dvd
eject /dev/dvdrw

If the CD/DVD rom support for closing tray (usually this feature exist on PC), you can also close the CD/DVD tray from command line.
eject -t

Here's list of parameters that you can use with 'eject' command:
       -h --help
       -v --verbose
       -d --default
       -a --auto
       -c --changerslot
       -t --trayclose
       -T --traytoggle
       -x --cdspeed
       -X --listspeed
       -n --noop
       -r --cdrom
       -s --scsi
       -f --floppy
       -q --tape
       -V --version
       -p --proc
       -m --no-unmount

No comments:

Post a Comment