Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/help/en/bash/eject.html
blob: 81b936281f407109d672f3a589bbeb6e6615131e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<link rel="STYLESHEET" href="../term_tools/main.css" type="text/css">
<title>eject MAN Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body><!-- #BeginLibraryItem "/Library/head_bash.lbi" --><div id="nav-menu">
<ul>
<li><a class="rl" href="../term_tools/index.html"><img src="../term_tools/images/ss64.gif" title="Home" alt="Home"></a></li>
<li><a class="rl" href="../term_tools/bash"><img src="../term_tools/images/bash-l.gif" title="bash" alt="bash"></a></li>
<li><!-- Search Google -->
<form action="http://www.google.com/search" method="get" style="margin:0px;padding:0px;">
<div align="right">
<input name="q" type="text" class="body" size="25">
<input class="submit" type="submit" value="Search">
<input type="hidden" name="q" value="site:ss64.com/bash/">
</div>
</form></li>
<li><a class="rr" href="syntax.html"><img src="../term_tools/images/syntax-r.gif" title="Bash Syntax"></a></li>
</ul>
</div> <!-- #EndLibraryItem --><h1>eject</h1> 
<p>Eject removable media </p>
<pre>Syntax
      eject -h
      eject [-vnrsfmqp] [&lt;name&gt;]
      eject [-vn] -d
      eject [-vn] -a on|off|1|0 [&lt;name&gt;]
      eject [-vn] -c slot [&lt;name&gt;]
      eject [-vn] -t [&lt;name&gt;]
      eject [-vn] -T [&lt;name&gt;]
      eject [-vn] -x &lt;speed&gt; [&lt;name&gt;]
      eject [-vn] -X [&lt;name&gt;]
      eject -V 
</pre>

<p>Description
</p>
<p>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.</p>
<p>The device corresponding to &lt;name&gt; is ejected. The name can be a device file or mount point, either a full path or with the leading &quot;/dev&quot;, &quot;/media&quot; or &quot;/mnt&quot; omitted. If no name is specified, the default name &quot;cdrom&quot; is used.</p>
<p>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.</p>
<p>If the device is currently mounted, it is unmounted before ejecting.<br>
Command-line Options</p>
<p>-h<br>
Help - displays a brief description of the command options. <br>
<br>
-v<br>
This makes eject run in verbose mode; more information is displayed about what the command is doing. <br>
<br>
-d<br>
If invoked with this option, eject lists the default device name. <br>
<br>
-a on|1|off|0<br>
This option controls the auto-eject mode, supported by some devices. When enabled, the drive automatically ejects when the device is closed. <br>
<br>
-c &lt;slot&gt;<br>
With this option a CD slot can be selected from an ATAPI/IDE CD-ROM changer. Linux 2.0 or higher is required to use this feature. The CD-ROM drive can not be in use (mounted data CD or playing a music CD) for a change request to work. Please also note that the first slot of the changer is referred to as 0, not 1. <br>
<br>
-t<br>
With this option the drive is given a CD-ROM tray close command. Not all devices support this command. <br>
<br>
-T<br>
With this option the drive is given a CD-ROM tray close command if it's opened, and a CD-ROM tray eject command if it's closed. Not all devices support this command, because it uses the above CD-ROM tray close command. <br>
<br>
-x &lt;speed&gt;<br>
With this option the drive is given a CD-ROM select speed command. The speed argument is a number indicating the desired speed (e.g. 8 for 8X speed), or 0 for maximum data rate. Not all devices support this command and you can only specify speeds that the drive is capable of. Every time the media is changed this option is cleared. This option can be used alone, or with the -t and -c options. <br>
<br>
-X<br>
With this option the CD-ROM drive will be probed to detect the available speeds. The output is a list of speeds which can be used as an argument of the -x option. This only works with Linux 2.6.13 or higher, on previous versions solely the maximum speed will be reported. Also note that some drive may not correctly report the speed and therefore this option does not work with them. <br>
<br>
-n<br>
With this option the selected device is displayed but no action is performed. <br>
<br>
-r<br>
This option specifies that the drive should be ejected using a CDROM eject command. <br>
<br>
-s<br>
This option specifies that the drive should be ejected using SCSI commands. <br>
<br>
-f<br>
This option specifies that the drive should be ejected using a removable floppy disk eject command. <br>
<br>
-q<br>
This option specifies that the drive should be ejected using a tape drive offline command. <br>
<br>
-p<br>
This option allow you to use /proc/mounts instead /etc/mtab. It also passes the -n option to umount(1). <br>
<br>
-m<br>
This option allows eject to work with device drivers which automatically mount removable media and therefore must be always mount()ed. The option tells eject <br>
to not try to unmount the given device, even if it is mounted according to /etc/mtab or /proc/mounts. <br>
<br>
-V<br>
This option causes eject to display the program version and exit.</p>
<p>Long Options<br>
All options have corresponding long names, as listed below. The long names can be abbreviated as long as they are unique.</p>
<p>-h --help<br>
-v --verbose<br>
-d --default<br>
-a --auto<br>
-c --changerslot<br>
-t --trayclose<br>
-T --traytoggle<br>
-x --cdspeed<br>
-X --listspeed<br>
-n --noop<br>
-r --cdrom<br>
-s --scsi<br>
-f --floppy<br>
-q --tape<br>
-V --version<br>
-p --proc<br>
-m --no-unmount</p>
<p><b>Examples</b></p>
<p>Eject the default device:</p>
<p class="code">eject</p>
<p>Eject a device or mount point named cdrom:</p>
<p class="code">eject cdrom</p>
<p>Eject using device name:</p>
<p class="code">eject /dev/cdrom</p>
<p>Eject using mount point:</p>
<p class="code">eject /mnt/cdrom/</p>
<p>Eject 4th IDE device:</p>
<p class="code">eject hdd</p>
<p>Eject first SCSI device:</p>
<p class="code">eject sda</p>
<p>Eject using SCSI partition name (e.g. a ZIP drive):</p>
<p class="code">eject sda4</p>
<p>Select 5th disc on multi-disc changer:</p>
<p class="code">eject -v -c4 /dev/cdrom</p>
<p>Turn on auto-eject on a SoundBlaster CD-ROM drive:</p>
<p class="code">eject -a on /dev/sbpcd</p>
<p><b>Exit Status</b></p>
<p>Returns 0 if operation was successful, 1 if operation failed or command syntax was not valid.</p>
<p><b>Notes</b></p>
<p>Eject only works with devices that support one or more of the four methods of ejecting. This includes most CD-ROM drives (IDE, SCSI, and proprietary), some SCSI tape drives, JAZ drives, ZIP drives (parallel port, SCSI, and IDE versions), and LS120 removable floppies. Users have also reported success with floppy drives on Sun SPARC and Apple Macintosh systems. If eject does not work, it is most likely a limitation of the kernel driver for the device and not the eject program itself.</p>
<p>The -r, -s, -f, and -q options allow controlling which methods are used to eject. More than one method can be specified. If none of these options are specified, it tries all four (this works fine in most cases).</p>
<p>Eject may not always be able to determine if the device is mounted (e.g. if it has several names). If the device name is a symbolic link, eject will follow the link and use the device that it points to.</p>
<p>If eject determines that the device can have multiple partitions, it will attempt to unmount all mounted partitions of the device before ejecting. If an unmount fails, the program will not attempt to eject the media.</p>
<p>You can eject an audio CD. Some CD-ROM drives will refuse to open the tray if the drive is empty. Some devices do not support the tray close command.</p>
<p>If the auto-eject feature is enabled, then the drive will always be ejected after running this command. Not all Linux kernel CD-ROM drivers support the auto-eject mode. There is no way to find out the state of the auto-eject mode.</p>
<p>You need appropriate privileges to access the device files. Running as root or setuid root is required to eject some devices (e.g. SCSI devices).</p>
<p>The heuristic used to find a device, given a name, is as follows. If the name ends in a trailing slash, it is removed (this is to support filenames generated using shell file name completion). If the name starts with '.' or '/', it tries to open it as a device file or mount point. If that fails, it tries prepending '/dev/', '/media/' ,'/mnt/', '/dev/cdroms', '/dev/rdsk/', '/dev/dsk/', and finally './' to the name, until a device file or mount point is found that can be opened. The program checks /etc/mtab for mounted devices. If that fails, it also checks /etc/fstab for mount points of currently unmounted devices.</p>
<p>Creating symbolic links such as /dev/cdrom or /dev/zip is recommended so that eject can determine the appropriate devices using easily remembered names.</p>
<p>To save typing you can create a shell alias for the eject options that work for your particular setup. </p>
<p><i>"I discovered that rejections are not altogether a bad thing. They teach a writer to rely on his own judgment and to say in his heart of hearts, 'To hell with you' - Saul Bellow</i></p>
<p><b>Related bash commands</b>:<br>
<br>
<a href="mount.html">mount</a> - Mount a file system<br>
umount - Unmount a device</p>
<!-- #BeginLibraryItem "/Library/foot_bash.lbi" --><p align="left"><script type="text/javascript"><!--
google_ad_client = "pub-6140977852749469";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="1984328893";
google_color_border = "CCCCCC";
google_color_bg = "CCCCCC";
google_color_link = "000000";
google_color_text = "333333";
google_color_url = "0000FF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>
</p>
<div align="center"><hr size="1">
  <p id="top"><a href="#"><img src="../term_tools/images/top-4.gif" width="47" height="53" border="0" alt="Back to the Top" title="Back to the Top"></a></p>
  <p class="tagline">&copy; Copyright <a href="http://ss64.com/">SS64.com</a> 1999-2010<br>
Some rights reserved<br>
</p>
</div><!-- #EndLibraryItem --></body>
</html>