The HFS+ volume on the following USB hard drive would not mount in Finder:
$ diskutil list
...
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *1.0 TB disk3
1: DOS_FAT_32 scratch 500.1 GB disk3s1
2: Apple_HFS foobar 500.1 GB disk3s2
so mounting in Terminal was attempted:
$ sudo mount -t hfs /dev/disk3s2 ~/temp/
Password:
mount_hfs: Permission denied
again:
$ sudo /System/Library/Filesystems/hfs.fs/hfs.util -MU disk3s2 ~/temp/ fixed readonly nosuid nodev
Password:
mount_hfs: Invalid argument
and again:
$ sudo diskutil mount readOnly /dev/disk3s2
Password:
Volume on disk3s2 failed to mount
If the volume is damaged, try the "readOnly" option
to no avail.
Next, the HFS+ volume was imaged with ddrescue:
$ sudo ddrescue -v /dev/disk3s2 ~/temp/foobar.dmg ~/temp/logfile.log
Attempting to mount the image failed as well:
$hdiutil attach -nomount ~/temp/foobar.dmg
/dev/disk5 $diskutil list
... /dev/disk5 #: TYPE NAME SIZE IDENTIFIER 0: foobar *500.1 GB disk5 $mount -t hfs -r /dev/disk5 ~/temp/
mount_hfs: Invalid argument $mount -t hfs -r /dev/disk5s0 ~/temp/
GetMasterBlock: Error 2 opening /dev/rdisk5s0 mount_hfs: No such file or directory $mount /dev/disk5 ~/temp/
mount: You must specify a filesystem type with -t. $diskutil mount readOnly /dev/disk5
Volume on disk5 failed to mount; if it has a partitioning scheme, use "diskutil mountDisk" If the volume is damaged, try the "readOnly" option $diskutil mountDisk readOnly /dev/disk5
Volume(s) mounted successfully
(Despite the promising "Volume(s) mounted successfully" message, nothing was mounted.)
$mount -t hfs -r /dev/disk5s0 ~/temp/
GetMasterBlock: Error 2 opening /dev/rdisk5s0 mount_hfs: No such file or directory $mount -t hfs -r /dev/disk5 ~/temp/
GetMasterBlock: Error 16 opening /dev/rdisk5 mount_hfs: Resource busy
Happily, a blog post by bbum entitled Recovering Disk Images with DiskWarrior held the answer:
sudo hdiutil mount -nomount -readwrite ~/temp/foobar.dmg
Indeed, DiskWarrior repaired the image successfully:
DiskWarrior has successfully built a new optimized directory for the disk named "foobar." The new directory is ready to replace the original directory.
...
The original directory is damaged and it was necessary to scavenge the directory to find file and folder data.
...
Comparison of the original and replacement directories could not be performed because the original directory was too severely damaged. It is recommended that you preview the replacement directory.
which was then mountable in Finder with just a double click.
UPDATE: On a related note, Recovering a non-readable disk on Mac OS X describes resolving a "The disk you inserted you inserted was not readable by this computer" error caused by a corrupt partition map via sudo gpt recover /dev/diskx
or diskutil repairDisk /dev/diskx
***
In another recent instance, an 8GB USB flash drive would not mount or even be recognized by the OS. After a dozen or so attempts, Disk Utility finally registered its presence, but reported that it was unformatted. diskutil list revealed it had been assigned to /dev/disk2, so imaging was begun:
sudo ddrescue -v /dev/disk2 ~/temp/flashdrive.dmg ~/temp/logfile.log
Over 12 hours later, imaging was complete.
As the image would not mount, testdisk was used to repair the partition table:
sudo testdisk ~/temp/flashdrive.dmg
(The testdisk steps are very simple, but here's a text-based screen recording of the process made with the awesome TermRecord, a "Terminal session recorder that outputs self-contained HTML".)
When testdisk completed, double clicking flashdrive.dmg mounted it easily in Finder.
/mac | Sep 10, 2015