Accessing raw unmountable Mac volumes
This evening I had to repair a family external hard drive. To run a few of my repair and recovery tools, I needed to give QEMU raw disk access to the drive on my Mac. Usually, this is a fairly easy task:
- Plug in the external drive
- Use “
diskutil list” to find the device identifier
- Unmount with “
hdiutil unmount /dev/diskX”
- Launch QEMU with “
The same could be done in VirtualBox using raw disk images.
In this case though, the volume was so badly corrupted that OS X got caught in a loop trying to mount it when the drive was plugged in. Manually mounting and unmounting didn’t work, and the system maintained a lock on the device.
There were several possible solutions, but I chose just to prevent that particilar drive automounting. First, find the UUID of the affected drive partition in question, where X is the drive and Y is the partition number:
$ diskutil info /dev/diskXsY
Then add the following to the legendary “
/etc/fstab” file, substituting the file system if you’re dealing with others. Newer versions of OS X don’t include the file by default, but still respect it if you create one:
$ sudo echo 'UUID=[from diskutil] none hfs rw,noauto' >> /etc/fstab
With that, I was able to plug the affected drive in, launch QEMU and be on my way.
Image of everyone’s favourite three star by saya556 on Pixiv. Because all the cool people, regardless of whether in anime or stock photography, diagnose their computer issues with a laptop on one leg.