Disk utility tip: Fix 'couldn’t unmount disk' errors

I have found myself recently experiencing a couple of Macs which would not allow me to repair the directory or permissions in Disk Utility, or erase/partition the drive with an error such as: ‘Disc erase failed couldn’t unmount disc’ or ‘Disk Erase failed with the error: Couldn’t unmount disk.’
couldnt unmount disk osx
Even trying to use Network Deployment tools such as Apple’s Netinstall service or DeployStudio have also failed to deploy due to these errors.
Normally, any ‘Couldn’t Unmount Disk’ error is attributed to circumstances where the boot drive is being modified or is being used by an application or process. So the first thing to do is to startup the Mac from another bootable drive such as an external drive or OS X Recovery. You can then run Disk Utility from there.
An external drive or a network drive is preferred if it is the internal hard drive you have an issue with, since the OS X Recovery is a partition on the same physical drive which may not be able to successfully unmount or modify your internal disk.
To create your own bootable disk, refer to our blog ‘Creating a Mavericks bootable install disk’.
I would strongly recommend at this stage attempting to back up any data that is required before proceeding with the following steps. Some of the following steps are destructive and will lose ALL data on your drive.

  1. If you have an external bootable disk, connect this to your Mac and power your Mac up whilst holding down the OPTION/ALT key. Then select the desired external drive from the startup manager screen and press the enter key.
  2. If you have used our method above to create a bootable installer, choose ‘Disk Utility’ from the available menu. If you have created your own bootable drive with a full system, open Disk Utility from /Applications/Utilities.
  3. Select the ‘First Aid’ tab and verify the troublesome disk, repairing if needed. Also perform a permissions repair if required.
  4. Attempt again to perform whichever task caused your ‘Couldn’t Unmount Disk’ error. (For example to Erase/Partition the disk).

Still not playing ball?
You can try booting from OS X Recovery (by holding ‘CMD’ + ‘R’ keys at startup) or an external drive and use the command line to attempt to unmount or erase the disk:
1) Once booted from OS X Recovery, select Terminal from the Utilities pull down menu. (Or if you are booting to your own bootable drive with a full system, open Disk Utility from /Applications/Utilities).
At the unix prompt enter:

diskutil list

Press RETURN. From the listing, look in the Identifier column for your disk identifier. It will look like ‘diskx’ where ‘x’ is an integer starting at 0. You should also see the name of the disk such as ‘Macintosh HD’. In my example below, the disk name is ‘Server’. Note down the disk identifier. For a single drive system this will probably be ‘disk0’ :

diskutil list

2) Now enter the following where ‘x’ is your disk identifier:

sudo diskutil unmountDisk /dev/diskx

3) Press RETURN. Enter your admin password if prompted. This should unmount all volumes of the physical drive:

unmount all volumes of the physical drive

4) Attempt again to perform whichever task caused your ‘Couldn’t Unmount Disk’ error. (For example to Erase/Partition the disk).
Still unable to work on the disk? Still getting those pesky disk errors?
Bit more drastic, but you can attempt to force a volume or the entire physical disk to unmount:
FOR A VOLUME:
1) Using the Terminal application again, booting from OS X Recovery or an external bootable drive,
Enter the following where ‘x’ is your disk identifier and ‘y’ is your volume identifier, (remember to use the ‘diskutil list’ command if you need to find out your disk and volume identifiers):

sudo diskutil unmount force /dev/diskxsy

2) Press RETURN. Enter your admin password if prompted. This should force unmount the volume:

force unmount the volume

3) Attempt again to perform whichever task caused your ‘Couldn’t Unmount Disk’ error. (For example to Erase/Partition the disk).
FOR AN ENTIRE PHYSICAL DISK:
1) Using the Terminal application again, booting from OS X Recovery or an external bootable drive.
Enter the following where ‘x’ is your disk identifier. (Remember to use the ‘diskutil list’ command if you need to find out your disk identifiers):

sudo diskutil unmount force /dev/diskx

2) Press RETURN. Enter your admin password if prompted. This should force unmount the entire physical disk and all its related volumes:

orce unmount the entire physical disk and all its related volumes

3) Attempt again to perform whichever task caused your ‘Couldn’t Unmount Disk’ error. (For example to Erase/Partition the disk).
OK, we’ve tried to be nice, but is the disk STILL not letting you work with it?
Be sure you backup your files to an external drive or second internal drive, the following procedure will remove everything from the hard drive!
We are now going to force erase the physical disk, creating a single Mac OS Extended (Journaled) volume. This should then allow you to partition and work with the physical disk again.
1) Using the Terminal application again, booting from OS X Recovery or an external bootable drive.
Enter the following where ‘MacintoshHD’ is the name of the newly created Mac formatted partition, and where ‘x’ is your disk identifier, (remember to use the ‘diskutil list’ command if you need to find out your disk identifiers):

sudo diskutil eraseDisk JHFS+ MacintoshHD diskx

2) Press RETURN. Enter your admin password if prompted. This should force erase the entire physical disk and all its related volumes, then create a single Mac OS Extended (Journaled) volume:

create a single Mac OS Extended (Journaled) volume

3) Hopefully you can now perform your desired erase, partition, installation or deployment on this drive.
NOTE: Use of the ‘sudo’ command may not be necessary for some of these actions, however, as long as you know the administrator account’s password, starting any unix command with ‘sudo’ will force the command to be run as the unix root user, so you shouldn’t have any permission issues executing the command.
Disclaimer:
While the author has taken care to provide our readers with accurate information, please use your discretion before acting upon information based on the blog post. Amsys will not compensate you in any way whatsoever if you ever happen to suffer a loss/inconvenience/damage because of/while making use of information in this blog.
This feature has been tested using OS X v10.9.2 which was the latest Mac OS release at the time of writing.