Use Terminal to Eject a Stuck CD/DVD

Terminal Trick Lets You Force Eject Media Without Shutting Down

A cd in a macbook disk drive
Epoxydude/Getty Images

Having a CD or DVD stuck in your Mac or an optical drive isn't a fun situation. And while there are a number of ways to force the media to be ejected, most require you to shut down. If that presents a problem, you can use Terminal to force eject the CD or DVD, without shutting down your Mac.

Terminal, an app included with the Mac OS, provides access to the Mac’s command line. The fact that the Mac has a command line is often times a bit of a shock to Mac users and Windows switchers.

But when you realize that OS X and the macOS is built using Unix components, such as the Mach kernel and portions of BSD (Berkeley Software Distribution), then it makes sense that a command line tool is available.

Perhaps even more important for the problem of a stuck CD or DVD in your optical drive is that Terminal includes a command for working with attached storage devices, such as an optical drive. This command, diskutil, can do quite a bit; in fact, it's the foundation for the Disk Utility app that's also included with the Mac.

We're going to make use of diskutil's ability to work with optical drives to force any stuck media in your optical drive to be ejected.

Use Terminal to Eject a Stuck CD or DVD

Launch Terminal, located at /Applications/Utilities.

In the Terminal window, enter one of the following three commands:

If you have a single optical drive:

drutil eject

If you have both an internal and external optical drive, use the appropriate command below, depending on which drive has the stuck CD or DVD:

drutil eject internal drutil eject external 

Press return or enter after entering one of the above commands in Terminal.

The stuck CD or DVD should be ejected.

The above should solve most stuck CD or DVD problems, but there's still another method for ejecting a stuck CD or DVD. In this case, the problem occurs when you have more than one internal or external optical drive.

In those conditions, you can use a different command, diskutil, to eject a specific device.

In order to issue the proper form of the eject command, you need to know the physical device name used by OS X for the optical drive that has the stuck disk.

Use Diskutil to Eject a Specific Drive's Media

If it's not already open, launch Terminal, located in the /Applications/Utilities folder.

To find out the optical drive's name, issue the following Terminal command:

diskutil list

diskutil will return a list of all the disks currently attached to your Mac. 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 would be: disk0, disk1, disk2, etc.

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

diskutil list output


0:GUID_partition_scheme 500 GBdisk0
1:EFIEFI209.7 MBdisk0s1
2:Apple_HFS Macintosh HD499.8 GBdisk0s2
3:Apple_Boot_RecoveryRecovery HD650 MBdisk0s3


0:Apple_partition_scheme 7.8 GBdisk1
1:Apple_partition_map 30.7 KBdisk1s1
2:Apple_Driver_ATAPI 1 GBdisk1s2
3:Apple_HFSMac OS X Install6.7 GBdisk1s3

In the above 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, then use just the base name of the identifier in the diskutil eject command.

As an example:

The DVD that is stuck in the Mac shows up as disk1s3. The stuck disk actually has three partitions on it: disk1s1, disk1s2, and disk1s3. 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.

Once you have the optical drive's identifier, in our example disk1, you're ready to use Terminal to eject the media from the specific drive.

At the Terminal prompt enter:

diskutil eject disk1

Press enter or return.

Remember to change the identifier in the above example to match the identifier you found using the diskutil list command.

You can quit Terminal.

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 paperclip and insert the now straight clip into the ejection hole. When you feel the paperclip pressed against an object, continue to push. The drive tray should start to eject. Once the tray is open a small amount you should be able to pull the tray the rest of the way out.

If you're still not able to eject the optical drive’s media, you may have to resort to using one the methods outlined in: How do I eject a CD or DVD from my Mac?

When all else fails an external optical drive that uses a tray to hold an optical disk can be manually opened. With the assistance of a small flat blade screwdriver locate the top of the tray and gently insert the tip of the screwdriver. You should be able to use the screwdriver as a lever and push the tray door open. Go slow, there will be some resistance, but the tray should open unless it is physically obstructed by the stuck optical media.​ That is one reason for avoiding those odd size discs that were popular at one time as a replacement for business cards.

Was this page helpful?