Use Terminal to Eject a Stuck CD/DVD

Use this Terminal trick to force eject media without shutting down

Having a CD or DVD stuck in your Mac or an optical drive isn't a fun situation. If you've already tried unsuccessfully to eject the disk using the File > Eject option, the Eject key, and restarting the Mac, it's time to turn to the Terminal app for help. You can use Terminal to force eject the CD or DVD without shutting down your Mac using the drutil and diskutil commands.

Information in this article applies to Macs running macOS Catalina (10.15) through OS X Lion (10.7).

Terminal, an app included with the Mac OS, provides access to Mac's command line. The fact that the Mac has a command line is often a shock to Mac users and Windows switchers, but when you realize that OS X and macOS are built using Unix components, it makes sense that a command line tool is available.

Terminal includes commands for working with attached storage devices, such as an optical drive.

MacBook Pro ejecting optical media
EpoxyDude / Getty Images

Use Terminal to Eject a Stuck CD or DVD

You can make use of diskutil's ability to work with optical drives to force any stuck media in your optical drive to be ejected. If your Mac has a single optical drive with a stuck disk, the simple approach will probably work for you.:

The Simple Approach to Ejecting a Stuck CD or DVD

  1. Launch Terminal, which is located at Applications > Utilities.

  2. In the Terminal window, type:

    drutil tray eject
  3. Press Return or Enter to eject the disk.

When the Simple Approach Doesn't Work

If the simple approach doesn't work, or your Mac has both an internal and external optical drive, you may need to do a little more work.

  1. Launch Terminal, which is located at Applications > Utilities.

  2. In the Terminal window, type:

    drutil tray
  3. Press Return or Enter.

  4. In the list, select the number of the drive you want to eject. (See how to determine the drive number in the next section.)

  5. Enter the following command into Terminal, substituting the number of the drive you identified for [drive].

    drutil tray eject [drive]

    For example, if the drive is disk1, the command is

    drutil tray eject 1
  6. Press Return or Enter to eject the drive.

To issue the proper form of the eject command, you need to know the physical device name used by the Mac for the optical drive with the stuck disk.

How to Identify the Drive

If it's not already open, launch Terminal and enter the following Terminal command:

diskutil list

A list of all the disks currently attached to your Mac is returned by the diskutil command. The Mac uses identifiers in the following format: diskx, where x is a number.

The Mac counts drives starting at 0 and adding 1 for each additional device it finds. Examples of the identifier then are disk0, disk1, disk2, and so on.

Under each disk identifier, you'll see a number of disk segments, corresponding to partitions the base disk has been divided into. You may see entries like this:

/dev/disk0

       
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme   500 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 499.8 GB disk0s2
3: Apple_Boot_Recovery Recovery HD 650 MB disk0s3

/dev/disk1

       
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme   7.8 GB disk1
1: Apple_partition_map   30.7 KB disk1s1
2: Apple_Driver_ATAPI   1 GB disk1s2
3: Apple_HFS Mac OS X Install 6.7 GB disk1s3
diskutil list output

In this example, there are two physical disks (disk0 and disk1), each containing additional partitions. To locate the devices corresponding to your optical drives, find the entries that have a type name of Apple_Driver_ATAPI. Read across to find the identifier, and then use just the base name of the identifier in the diskutil eject command.

An Example

The Apple_Driver_ATAPI is a good way to distinguish which device is the optical drive, as it is only used with Apple's Super Drive and any third-party CD/DVD devices. The DVD that is stuck in the Mac is disk1. The stuck disk has three partitions on it: disk1s1, disk1s2, and disk1s3. You only need the base name — disk1.

After you have the optical drive's identifier, you're ready to use Terminal to eject the media from the specific drive.

External DVD Drives

If the stuck media is in an external DVD drive, there is a good chance that it may have an emergency disk eject system. This simple system consists of a small hole usually located just below the DVD drive tray.

To eject a stuck DVD, unfold a paper clip and insert the now straight clip into the ejection hole. When you feel the paper clip press against an object, continue to push. The drive tray should start to eject. When the tray is open a small amount, you can pull the tray the rest of the way out.