Repair a Mac OS X HFS+ Partition table

At the time of writing this post I must say that I feel like a hero! That feeling is wonderful you know, when someone has a problem with their computer and not a simple but a HUGE one and you are able to repair em you turn to be that people hero.

Today my friend Avaco12 made a little mistake while installing bootcamp on her iMac, she left her external (200GB) disk connected, and when Windows asked her where to put the new Partition she accidentally selected her preciousus external drive, when she realized it was already too late, windows had already destroyed the partition table on her disk. She had 1 HFS parition and 1 FAT. She was crying because she said she had her entire life on that disk, so she asked me for help and I started researching what could I possibly do to repair the disk or at least retrieve her data.

There are plenty of solutions out there, some of them are really expensive, and people on the forums are not very happy with them so I wanted to look at little more into the issue and I came across this solution called TestDisk which is an Open-Source Multi-platform solution for repairing disk partitions. I gave it a try and awesomely I managed to fix the disk using TestDisk and the pdisk utility.

When I called Avaco12 to tell her that I fixed her data she was so happy she couldn't stop smiling she told me I was her Hero and so that's how I felt, the process wasn't easy specially because noone talks about how pdisk works on Mac OS X.

Here's how I did it , hope it works for you.

1.- I downloaded TestDisk from their official site :http://www.cgsecurity.org/wiki/TestDisk

2.- I opened the terminal and surfed to where I downloaded and unziped TestDisk

3.- I issued the command 'sudo ./testdisk' it indetially promped me to make my terminal bigger =P, after doing so It displayed me a simple disclaimer and then a notice telling me that TestDisk could Log all the activity if I wanted to. I selected Yes and continued.

4.- On the screen it will display you all the Disk it detects connected to your Mac select the one that got damaged partition tables and press Enter. Take note of which drive you selected, in my case I chosed /dev/rdisk1 (rather than /dev/disk1)

5.- Next screen select the menu Analize, it will probbly display you and error telling you the block 0 couldn't be read, just hit enter on the 'Quick Analize' option

6.- ATTENTION: TestDisk will quickly search for partitions on the disk and display you information about it on your disk. Take note of the information it will display you, since you'll need it to repair the disk later on with pdisk.

Here's a screenshot of what I got:

Note: if you try to repair your partition table with TestDisk it will fail since that function is not yet implemented.

7.- you can now exit TestDisk. The next steps are what distinguish a child from a Men

8.- Issue the command 'sudo pdisk /dev/rdisk1' (where /dev/rdisk1 should be the same name you chosed on step 4). If you type the command 'c' and hit enter it will tell you the following:

9.- That's completely normal. Now type 'i' and it will display you some affirmations about block sizes and such, just hit enter:

10.- Now we are going to need the info from Step 6. type the command 'c' and press enter, it will ask you to type down where your first partition starts, how long it is and how you want to name it. repeat this step for every partition you have.

11. Now if you are completely sure you wrote down everything correctly (like I did) just type down 'w' and hit Enter, It will prompt you to confirm just say yes (y)

12. type 'q' to quit the application and go see for yourself if your disk appears now in Finder. If it does, go to Step 13. else try again.

13. You are a hero, no matter if it's your own disk, you just saved your info!

Congratulations, and I hope this information is usefull to you !

You can buy me a drink if you'd like to share your joy :)

Feel free to contact me with any problems you get at : perro.hunter@gmail.com

cheers !

Shinobi
Worked like a charm thanks man !
  • Reply
  • Report
PERR0_HUNTEr
Im glad it worked for you
  • Reply
  • Report
alcomposer
This is the sort of advice that should be on late night television- but wait there is MORE! Retrieve ALL of your data NOW- no File Carving- no rebuilding Indexes, no FSCK, simply put- its PDISK and its on a mac near you! :D (Sorry- complete and absolute file recovery can cause extreme excitement and euphoria)
  • Reply
  • Report
finger
Hi dog hunter!
I would kiss you if I can! I've just recovered a partition that Partition Magic (from a boot cd) dreaded up! It "fixed" an error, and the driver never worked again. I found that the problem was a wrong Partition Table, and your explanation was quite helpfull. Althouth, I was able to do everything from TestDisk! Yeah, its true. After a QuickSearch, I have set the right Partition Types (which the program have correctly detected) and selected the program to write the partition table. The program told me to reboot, and voila! (using a disk formated as GUID with a unique partition as HFS+)
Long live the hunt!
  • Reply
  • Report
PERR0_HUNTER
Great ! is good to know this post is helping a lot of people :D have a nice day
  • Reply
  • Report
nerual13
Holy god, you are my hero right now! Bootcamp snuffed my partition table, but the world has been made right again!!! THANK YOU!!!!!!
  • Reply
  • Report
Runar
I manually fucked up my 500gb backup drive when attempting to make Windows 7 read NFS+ drives, and I thought I had lost it all when OS X didn't seem to read it.

Thanks to you, and TestDisk, I got my data back! I have never been this happy in a long time!

Thank you!
  • Reply
  • Report
Paul
thanks, this worked great. Windows 7 hosed my HSF partition cause it initiated the disk. I tried various tools nothing worked. Followed your step and everything worked, the only thing that i needed to do was scan for my partition a bit it didnt show up in the first quick scan
  • Reply
  • Report
Chris
You are da man! My 1T external became unreadable and unrepairable after an app crashed while copying files. Your procedure worked like a charm.
  • Reply
  • Report
Danny
Thanks for your help. That was excellent. I accidently overwrote my partition table when I connected my osx exernal drive to a XP system and lost all my data. Now it is back .... thanks goodness. Cheers
  • Reply
  • Report
Randy J
Does anyone know how do fix the Mac partition from the Windows partition? I already have the log from TestDisk.
  • Reply
  • Report
PERR0_HUNTER
Hey Randy ! you could try to use your OS X Installation disc, just insert it, when you get the the main menu, on the apple menu go to Utilities> terminal, and from there use pdisk :D ! plz tell me if this worked :) cheers
  • Reply
  • Report
Randy J
How can I open pdisk once I am in the terminal? Should it have been previously installed in the Mac OS Partition?
  • Reply
  • Report
PERR0_HUNTER
Not necesarely :)
  • Reply
  • Report
Leave a comment
Name:
Email:
Comment: