Disk Utility won't Unmount HD for formatting
I have two internal drives in my 27" iMac (10.8.5). An SSD system disk and a 1TB SATA drive.
The HDD has been acting up recently, very slow performance, bad behavior etc. Tech Tool Pro and Disk Utility don't seem to be able to fix the drive, so I decided to wipe the data by a reformat and writing zeros to the entire drive.
Everytime I try and format, it tells me that the drive cannot be unmounted. I have rebooted a few times, and spent days running everything from TechTool Pro on it and it won't go.
$ diskutil list disk2
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *4.0 TB disk2
1: EFI EFI 314.6 MB disk2s1
2: Apple_HFS Everest 4.0 TB disk2s2
$ diskutil repairVolume /dev/disk2s2
Started file system repair on disk2s2 Everest
Updating boot support partitions for the volume as required
Error: -69673: Unable to unmount volume for repair
$ diskutil eraseDisk JHFS+ Everest /dev/disk2
Started erase on disk2
Unmounting disk
Error: -69888: Couldn't unmount disk
Any thoughts on how to get it to unmount and reformatted? Is there a way in Terminal to do this instead?
You can force unmount a drive by running the following Terminal command:
diskutil unmountDisk force /Volumes/VOLUMENAME
Replace VOLUMENAME
with the name of a volume on the disk you are trying to unmount.
Following this, attempt to Erase/Partition the drive again in Disk Utility. Using the above command can interrupt file read/writes, which can cause file corruption. However, since you are erasing the drive anyway, this doesn't really matter in your situation.
When a disk is first connected, macOS helpfully tries to run fsck on the volume. If the volume is large or has extensive problems, this process can run for a long time before it fails.
The following Terminal command should identify the process at fault:
sudo lsof | grep diskn
replacing diskn with the number of the offending disk.
Once you have the process ID, you can kill it thus:
sudo kill -9 pid
replacing pid with the process ID determined above.
Then you can run diskutil normally, either from GUI or command line.
Disable Spotlight for that Hard Drive (System Preferences)
https://discussions.apple.com/thread/1454712?start=0&tstart=0