Today, as I intended to perform my regular Time Machine backup, I got welcomed by a very scary message when I connected my external hard disk to my MacBook.

Image

The disk you inserted you inserted was not readable by this computer.

Now, I take pride in having never ever lost any data on my Macs since 1998, so I was concerned this might be the end of my record…

In Disk Utility the drive device was listed, but no volume could be mounted due to a corrupted partition map. Don’t ask me how it got corrupted in the first place. I would guess the disk did not like being unplugged without using the eject command…

Anyway, salvation can come at no cost by using the Terminal in Mac OS X (assuming you have administrative rights):

  1. Connect your external disk
  2. Start terminal and use the 3 commands in bold red below (make sure to change the disk number to match your setup based on the first command)
  3. If the last command was successful, disconnect and reconnect your disk, which should now be OK
IronMan:~ nbalkota$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *250.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS IronMan 249.2 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *1.0 TB disk1
1: 0xEE 1.0 TB disk1s1
IronMan:~ nbalkota$ sudo gpt recover /dev/disk1

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
gpt recover: /dev/disk1: recovered primary GPT table from secondary
gpt recover: /dev/disk1: recovered primary GPT header from secondary
IronMan:~ nbalkota$ diskutil eject /dev/disk1
Disk /dev/disk1 ejected

An alternative to the second command (gpt) would be diskutil repairDisk /dev/disk1

Note than the manpage for gpt does not cover the recover option whereas the manpage for diskutil does cover the repairDisk option.

Advertisement