Use Terminal to Eject a Stuck CD DVD
Use Terminal to Eject a Stuck CD/DVD GA S REGULAR Menu Lifewire Tech for Humans Newsletter! Search Close GO Computers, Laptops & Tablets > Apple
Press Return or Enter to eject the disk.
Press Return or Enter. In the list, select the number of the drive you want to eject. (See how to determine the drive number in the next section.) 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
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.
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.
Use Terminal to Eject a Stuck CD/DVD
Use this Terminal trick to force eject media without shutting down
By Tom Nelson Tom Nelson Writer Tom Nelson is an engineer, programmer, network manager, and computer network and systems designer who has written for Other World Computing,and others. Tom is also president of Coyote Moon, Inc., a Macintosh and Windows consulting firm. lifewire's editorial guidelines Updated on July 16, 2020 Tweet Share Email Tweet Share EmailIn This Article
Expand Jump to a Section Use Terminal to Eject a Disc How to Identify the Drive An Example External DVD Drives 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. EpoxyDude / Getty ImagesUse 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
Launch Terminal, which is located at Applications > Utilities. In the Terminal window, type: drutil tray ejectPress 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. Launch Terminal, which is located at Applications > Utilities. In the Terminal window, type: drutil trayPress Return or Enter. In the list, select the number of the drive you want to eject. (See how to determine the drive number in the next section.) 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
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 listA 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.