Recovering from an external drive failure on Mac

A few weeks ago I plugged the external USB hard drive that holds my photo library into my Mac, and was greeted with the following message:

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

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

 

Bummer. As it happened, I didn’t have an up-to-date backup of the drive, having made some recent updates. I really needed to recover the contents of the drive. I tried the drive in another Mac, and got the same message. I tried it in a Windows machine, and got a message about an error with the drive.

I plugged it back into the Mac and had a look at Disk Utility. It showed the drive in the left pane, but with no associated volumes. On the First Aid tab, the Verify Disk and Repair Disk items were grayed out. In the disk info section at the bottom, the following telltale appeared: “Partition Map Scheme: Unformatted”. It was clear that the partition table had been corrupted somehow.

I gave up on the GUI tools and switched to diskutil, which is OSX’s tool to manage disks, volumes, and partitions.

 

The list command shows the available drives:

[21:07:16] mini-me ~ $ diskutil  list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacintoshHD             119.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.5 TB     disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS BigMedia                1.5 TB     disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   *1.0 TB     disk2

 

Lines 13-15 (disk2) represent the drive in question. Note that there are no partition types or volume names, nor are there any partitions. diskutil has several repair verbs. One of them, repairDisk, exists specifically to fix a busted partition map:

Repair the components of a partition map of a disk

 

I am certain that this drive used to be partitioned using the GUID partition scheme (the default under OSX), so answered yes to the confirmation question:

[21:08:23] mini-me ~ $ diskutil repairDisk /dev/disk2
Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition map,
you can hereby try to repair it enough to be recognized as a map; another
"diskutil repairDisk /dev/disk2" might then be necessary for further repairs
Proceed? (y/N) y
Partition map repair complete; you might now want to repeat the
verifyDisk or repairDisk verbs to perform further checks and repairs

 

That seems to have fixed it; diskutil now recognized the two partitions from the external drive:

[21:08:52] mini-me ~ $ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacintoshHD             119.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.5 TB     disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:                  Apple_HFS BigMedia                1.5 TB     disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS TimeMachine             150.0 GB   disk2s2
   3:                  Apple_HFS Mercury                 849.7 GB   disk2s3

 

To confirm that the partition really was restored, mount up the disk:

[21:09:47] mini-me ~ $ diskutil mountDisk /dev/disk2
Volume(s) mounted successfully

[21:09:53] mini-me ~ $ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk2s2 on /Volumes/TimeMachine (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk2s3 on /Volumes/Mercury (hfs, local, nodev, nosuid, journaled, noowners)

 

I manually checked the contents of the two partitions, and they appeared to be correct. All the files were readable and I didn’t notice anything missing. Disaster averted!

If diskutil had been unable to recover my files, there are some alternatives:

  • TeskDisk: Data recovery software to rebuild or recover from partition/filesystem problems
  • PhotoRec: Block-by-block recovery software for known file types
  • GParted: graphical partition editor

In addition, there are several commercial disk-recovery applications available.

 

A note on backups: as I mentioned at the beginning of this post, my backup of the data on this disk was out of date.  As I tried to recover them, I realized just how important that data was.  To avoid the recurrence of this problem in the future, I implemented a backup strategy for irreplaceable data:

  1. Master data stored on my machine’s internal drive
  2. Frequent backups, using <code>rsync</code>, to a local external backup drive
  3. Less frequent backups to an EBS volume in Amazon EC2-land (again using <code>rsync</code>)

A future move will be to switch to RAID1 or RAID5 storage locally, to be able to handle a hardware failure.

Advertisements

28 thoughts on “Recovering from an external drive failure on Mac

  1. Scott Wallace

    Nice post. Great to hear from you and I hope you’re living life to the full, as I know you are!

    FWIW, for photos I’m using an Eye-Fi SD card and am uploading to SmugMug (unlimited online storage) on-the-fly. Not sure how to backup those (except an rsync to my local NAS-server).

    Google Drive for the rest.

    Like

    Reply
    1. simpsora Post author

      Hey Scott!

      I thought about Eye-Fi cards, but they’re not large enough or fast enough for me at the moment (I’m using 2 64GB UFS-1 cards), but it is an interesting idea. I’m having some good luck with the EC2 backup process. The initial backup is taking ages, but I like the fact that my data will be stored on redundant disks in multiple datacenters. I’m using an EC2 instance backed with an EBS store, so that I can rsync directly to it (as opposed to using MacFUSE or similar to access an S3 store). One other primary goal was for my backups to be in the native format, not in a proprietary backup format.

      Plus, if you keep your usage under a certain limit, you get the first year free with AWS 🙂

      PM sent!
      Ross

      Like

      Reply
      1. Scott Wallace

        The Eye-Fi cards can run in endless memory mode. i.e. it overwrites the oldest, successfully transferred photos automatically. This requires that the Eye-Fi card can transfer images off before you run out of space.

        As the Eye-Fi card becomes a WiFi hotspot, my mobile phone automatically connects and transfers the photos off in near realtime meaning that the photos taken on my camera are uploaded to the Internet within minutes of taking them.

        As SmugMug runs on AWS, I presume that ends up being replicated as you’ve described above. SmugMug allows for the full images to be stored and in their native format (not sure about RAW). They have a pretty good API (which I use via Google App Engine to serve photos for my daughter’s website) and there are plenty of scripts available if you really want to backup offline.

        (Anyone would think that I’m on commission!)

        Like

  2. Augusto

    I have the same problem but when I run this line: diskutil repairDisk /dev/disk2 I get this error: Error repairing map: Couldn’t read partition map (-69876)

    Some advice?

    Like

    Reply
    1. simpsora Post author

      Augusto,

      I haven’t seen that particular error before, but some searching indicates it may be related to an encrypted partition. Are/were any of your partitions encrypted?

      Like

      Reply
  3. Jera

    Hi,

    I have the same prblm as everyone else and when i did a recovery this is what i get

    ”Error encountered attempting to verify/repair disk2: Unrecognized filesystem (-9958)”

    does this mean my drive is completely damaged

    Like

    Reply
    1. simpsora Post author

      Jera, see my answer to Mike above — he has the same problem as you, and the same solution may help you as well. It’s not necessarily a damaged drive (mine wasn’t), but it’s hard to say. Try out TestDisk and see if you can recover that way.

      Like

      Reply
  4. Mike

    when i enter : diskutil repairDisk /dev/disk1

    it says : Nonexistent, unknown, or damaged partition map scheme
    If you are sure this disk contains a (damaged) APM, MBR, or GPT partition map,
    you can hereby try to repair it enough to be recognized as a map; another
    “diskutil repairDisk /dev/disk1” might then be necessary for further repairs
    Proceed? (y/N)

    Then i enter: Y

    it says : Error repairing map: MediaKit reports bad partition or no map found (-5324)

    What do i do plz help ……

    Liked by 1 person

    Reply
    1. simpsora Post author

      Hi Mike,

      I have recently experienced this error as well. In my case,it turned out to be a corrupt partition map. I used TestDisk (see the link in the original post) to recover from this error, and the drive has worked fine ever since.

      See the link below for the steps I followed to correct the error. I didn’t actually need to enter the new block sizes as described — TestDisk recognized an error and let me rebuild the partition map, which fixed it.
      http://perrohunter.com/repair-a-mac-os-x-hfs-partition-table/

      Good luck!

      Like

      Reply
  5. Juan

    I did as these adviced but when I repair disk, it show a msg : Mediakit report bad parttion….

    And The result from testdisk is very messy. So I do not know what is next step. Could you please help me. This HDD has all my data. Thank you very much.

    Disk /dev/rdisk1 – 500 GB / 465 GiB – 976711728 sectors
    Partition Start End Size in sectors
    > Mac HFS 974201231 975470766 1269536
    Mac HFS 974201296 975470831 1269536
    Mac HFS 974201393 975470928 1269536
    Mac HFS 974201458 975470993 1269536
    Mac HFS 974201555 975471090 1269536
    Mac HFS 974201620 975471155 1269536
    Mac HFS 974201717 975471252 1269536
    Mac HFS 974201782 975471317 1269536
    Mac HFS 974201855 975471390 1269536
    Mac HFS 974201920 975471455 1269536
    Mac HFS 974202017 975471552 1269536
    Mac HFS 974202082 975471617 1269536
    Mac HFS 974202179 975471714 1269536
    Mac HFS 974202244 975471779 1269536
    Mac HFS 974202341 975471876 1269536
    Mac HFS 974202406 975471941 1269536
    Mac HFS 974202503 975472038 1269536
    Mac HFS 974202568 975472103 1269536
    Mac HFS 974202665 975472200 1269536
    … etc

    Like

    Reply
    1. Ross Simpson Post author

      Hi Juan,

      Sorry to hear that. It appears from that output that your disk is corrupt, unless you really did have 19+ HFS partitions of exactly the same size. If you know the size of the partition(s) before the corruption occurred, you could probably use TestDisk or gparted to repair the partition table. Otherwise all I suggest is that you try your hand at TestDisk and see if it can help you — yes, it’s messy, but that’s unfortunately the position you’re in.

      Good luck!

      Like

      Reply
  6. Hani ALHARIRI

    Hey Ross,
    very interesting stuff, thanks Ross.
    I have the same problem that Mike had, i tried test disk, but it was not recognized as disk2 , although it appears in disk utility, but with grayed verify disk and repair
    Is there any other option I can try plz
    Thanks

    Like

    Reply
  7. Radhika

    I am experiencing this problem, but am not at all techy enough to understand the solution. Please explain in baby language what steps to follow if at all possible. Any help would be much appreciated! Thank you

    Like

    Reply
    1. Ross Simpson Post author

      Hi Radhika,

      Fixing this problem is fairly complex, and mistakes can easily lead to data loss. I’d suggest finding someone who’s familiar with working in the terminal to help you.

      Like

      Reply
  8. toddrichards70

    This have been very helpful Ross. When I run the diskutil repairDisk and answer yes, I get “Error repairing Map: POSIX reports input/output error (5). Any ideas what that means?

    Like

    Reply
    1. simpsora Post author

      Hi Todd,

      Can you get any useful info from diskutil info DEVICENAME? I don’t know for sure, but it sounds like your device could have physical damage, which is not easily recoverable. You could try TestDisk, or failing that PhotoRec. Other than that, you may be out of luck. Hopefully you find a workable solution — if so, please let me know what it is!

      Like

      Reply
  9. rathakate

    hi
    after i use repairDisk . then i got — Error repairing map: POSIX reports: Input/output error (5)
    What should i do for this case?

    Like

    Reply
  10. mayank

    /dev/disk4
    #: TYPE NAME SIZE IDENTIFIER
    0: *750.2 GB disk4
    /dev/disk5
    #: TYPE NAME SIZE IDENTIFIER
    0: GUID_partition_scheme *122.9 MB disk5
    1: Apple_HFS EaseUS Data Recovery… 122.8 MB disk5s1
    /dev/disk6
    #: TYPE NAME SIZE IDENTIFIER
    0: GUID_partition_scheme *122.9 MB disk6
    1: Apple_HFS EaseUS Data Recovery… 122.8 MB disk6s1
    Mayank-Mac-mini:~ mayank$ diskutil repairDisk /dev/disk4
    Nonexistent, unknown, or damaged partition map scheme
    If you are sure this disk contains a (damaged) APM, MBR, or GPT partition map,
    you can hereby try to repair it enough to be recognized as a map; another
    “diskutil repairDisk /dev/disk4” might then be necessary for further repairs
    Proceed? (y/N) y
    Error repairing map: POSIX reports: Input/output error (5)
    Mayank-Mac-mini:~ $

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s