2

I booted to a live ubuntu USB, wanting to delete partitions on an SD card, and ended up deleting all my partitions on my mac book pro's internal hd.

I have already tried gpart (which gets stuck at "Begin scan...") and testdisk (which can't create partitions since "Function write_part_mac not implemented"!).

I did try "cmd + r" at boot, but gave it up as it was taking a long time. I thought there would be an easier and faster alternative.

Is there a way to recover data with partitions on my hd?

***EDIT: Here's my testdisk o/p for the mac hd:

 Partition               Start        End    Size in sectors

P DOS_FAT_32 40 409639 409600 [EFI]

P HFS 409640 489972567 489562928

3
  • 1
    Try using gdisk x extra functionality (experts only), then within the expert menu b use backup GPT header (rebuilding main). If you have a second metadata copy then you should be able to rebuild the partition table. – bsd Dec 31 '14 at 10:25
  • @bdowning... Thanks.. I'm sorry but I'm not well acquainted with gdisk tool. Could you please explain how I could rebuild the partition table? Should I use the testdisk output? – user3490458 Dec 31 '14 at 10:30
  • @bdowning I have edited my question to add testdisk o/p for the hd. Could you please have a look? – user3490458 Dec 31 '14 at 10:38
1

Intel MacBook Pro's use GUID partition table for disk partitioning which one can edit with gdisk.

A copy of the partition table metadata is usually stored as backup of the primary. You can read more detail about it on the Arch Wiki here

You need first to know the device name, /dev/sda, /dev/sdb of your Mac disk.
You can use the blkid, lsblk or dmesg commands to determine the exact name if you do not know.

From your Ubuntu Live USB, use gdisk /dev/sdX (where X is your device name)

e.g. /dev/sdb (assuming the USB is given sda and the Mac is the only other disk)

$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): `r`

Recovery/transformation command (? for help): `b` 

Recovery/transformation command (? for help): `w`

And reboot

The b restores the backup GUID partition table and w writes it to disk

You way wish to also run the v verify after restoring the backup table and before writing it to the disk. gdisk is very sane about letting one create and modify the partition table, in memory, and nothing is written on disk until you write it with the w command. Be very sure you are happy with the recovery result before you write it to disk.

2
  • Thanks a lot! I did as you said. But I don't see any partitions when I run 'v'. I had tried apple's internet recovery some time back. Is it possible that the internet recovery messed up the partition table meta data backup? – user3490458 Dec 31 '14 at 12:52
  • 1
    p shows the partition table, v simply verifies the table and hopefully prints "No problems found." – bsd Dec 31 '14 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.