DidactiCOde
  • Home
  • Works
  • Blog
  • Social
  • About

Guide: Mac Partition Recovery; Part2: Backup

5/28/2016

Comments

 
Picture
Continued from part1...
Partiton table backup is not something one would normally consider in a single partition scheme; less so on a Mac because these systems are generally "kept simple." However, the partition scheme may not be as "simple" as we think. In the case of Macs what is displayed in Disk Utility does not even begin to describe the system disk's true structure.
Picture
Healthy Mac Partition Table
Picture
Corrupt Mac Parition Table
On Macs, the gpt command is the low-level partition editor required to configure the GPT. Please use an installation or recovery disk because booting from the recovery partition of the affected disk will mount it, making low-level operations impossible. It is also just good practice.
Display the mounted volumes:
mac# df
Unmount the affected disk's volumes that are automatically mounted by the recovery system:
mac# diskutil unmount /Volumes/[volume name]
Display the partition table(replacing disk0 with disk* as necessary):
mac# gpt show disk0
Take a photograph of the displayed data. The sector numbers and sizes proved critical to restoring my disk.

Mac's "gpt" command does not offer the ability to save the partition table to a file so we need to boot another "unix" to do this. (Remember what I said about gpt tools not being mature?) As you can see in the images above, I had lost everything but "Systems" so the Mac couldn't boot. Fortunately, the sector numbers were correct and the other unix systems could see different pieces of the missing information.
Picture
Ubuntu's view of the corrupt table
Picture
NetBSD's view of a healthy table
Insert your selected unix system disk and restart your Mac, holding down the "Option" key before the startup chime. Select the unix system at the next prompt and run it. Open a terminal when ready.

If your system automatically mounts any disks, unmount them
umount /dev/[disk]
Proceed very carefully from here on! These are the GPT editors in the systems I investigated: Ubuntu Linux(gdisk which might need to be downloaded), FreeBSD(gpart), NetBSD(gpt), OpenBSD(fdisk). While Linux's gdisk has an interactive mode and does not write changes unless you say so, all the other editors work in a "command mode.". We have to issue single commands with relevant options to perform a single operation that is FINAL. Please be careful.

I settled on NetBSD and Ubuntu but, as I mentioned, GPT utilities are not mature and I encountered issues in both. gpt did not properly display the entire partition information with the labels assigned by OS X and gdisk could not write changes to the misconfigured "special" partitions. gdisk had the more informative display but I felt gpt was more "powerful" (with great power comes…)

Both are able to backup and restore the raw partition table to a file so their incomplete interpretation of the data was not a showstopper. I used gpt for the backup.

On Linux enter "linux# gdisk /dev/sd[letter]" and then "p" to display the table.
Type "r" for recovery and you will have the option to backup to a file

On NetBSD enter "netbsd# gpt show wd[number]" to display the table.
Type "netbsd# gpt backup wd[number] > [file path]" to backup the table.

It was a relief to see that the structure was intact and that only the partition types and numbers were changed. My ultimate goal was to somehow get a bootable Mac Recovery Disk from the Recovery Partition. Reading about GPT partition types allowed me to set the correct type GUID and it became visible at boot. Unfortunately, the missing system partition and general "incorrectness" of the table prevented my Mac from completing the boot process. My next step was to copy that partition to a USB disk.

Continued in part3...
Comments
comments powered by Disqus

    Categories

    All
    BlackBerry
    Computing
    Technology

    Archives

    February 2017
    May 2016

    CA Canadian Domain Name Registration and Web Site Hosting
Site powered by Weebly. Managed by Web Hosting Canada
  • Home
  • Works
  • Blog
  • Social
  • About