Code Blog

Displaying 1-1 of 1 result.
2016/02/15 MacOSX

I have been running into problems with my external HDD (Toshiba 1TB) when I've been in a hurry (read: too lazy) to properly eject the drive from my MacBook Air. The problem is when I plug the drive back in it just won't reappear in the finder window and even rebooting the Mac OS often won't solve the problem (it worked sometimes). This was getting rather annoying wasting a lot of time rebooting the system and still not being able to access the external HDD.
I noticed that the system has actually found the drive but did not re-attach it (mount it); I would guess this is because the OS detected a potential error and wants to protect the disk data. I found it easiest to mount the drive directly from the command line to solve this problem.

Open terminal window and run:

diskutil list

The diskutil will list all HDDs attached to your system. For my system /dev/disk0 is the internal physical drive, and /dev/disk1 is an internal virtual drive.

/dev/disk2 (external, physical):
   #:       TYPE NAME                      SIZE        IDENTIFIER
   0:       FDisk_partition_scheme         *1.0 TB     disk2
   1:       Windows_NTFS TOSHIBA EXT        1.0 TB     disk2s1

Here the diskutil listed the external HDD I want to mount with identifier /dev/disk2s1 (Windows_NTFS file partition type, filesystem is exFAT). The "s" stands for slice, which means the same thing as partition.

diskutil info /dev/disk2s1

Run the "info" option to list information about the device. It will show if it is mounted and the mount point. It also lists the filesystem used; I use exFAT for my Mac/Windows external drive.

diskutil unmount /dev/disk2s1

Here the output should be: "was already unmounted"

diskutil mount /dev/disk2s1

If output is "Volume on disk2s1 timed out waiting to mount" then try again using the "force" flag i.e. "diskutil mount force /dev/disk2s1". This used to work great for me in the past, but after recent Mac OS X updates this option seems to have been dropped from the diskutil command utility! Now I just have to wait ~5 min and after that I can mount the disk again.

On a side note "diskutil activity" may be useful to debug problems when mounting/unmounting partitions (in another terminal window). The man doc writes: "Continuously display system-wide disk manipulation activity ... This can be useful to watch system-wide activity of disks coming on-line or being ejected, volumes on disks being mounted or unmounted, volumes being renamed, etc.".

Another useful function of diskutil is the "diskutil secureErase level device" command which will zero out the entire HDD using a secure method (the "level" option selects which method to use). Save that for another time.