PDA

View Full Version : Recovering your GUID Partition Table (restoring the PMBR)


jerbare
17th March 2006, 05:10 PM
UPDATE: There are reports that the recently released (Boot Camp required) Firmware Update will not install if you have an XOM installation. This is due to the EFI partition not being properly recognized, which is needed to update the EFI firmware. There have been several reports that following these instructions to restore the PMBR have allowed people to retain their existing Windows XOM installations and use Apple's updated "Boot Camp" OS loader instead of xom.efi.

WARNING: It would be nice if someone with experience to the following process could verify my work. Those who want to attempt recovery should wait until such verification has occurred. You should also have familiarity with standard UNIX shell commands and knowledge of the various paths and locations of mounted volumes in Mac OS X. With that in mind, please follow these instructions VERY CAREFULLY. Quadruple-check any command being executed in the Terminal. Some of the instructions peform raw editing of the disk that can damage things worse than they already are if done incorrectly. Familiarity with the UNIX utility 'dd' is preferred. I cannot be held responsible for further loss of data. DO THIS AT YOUR OWN RISK.

Okay, as long as you haven't repartitioned or changed anything to your disk since running xom.efi you should still have a primary and secondary GUID partition table intact that can be read from the gpt application. DO NOT repartition or format the internal disk (obviously, because we are attempting to rescue it).

http://en.wikipedia.org/wiki/Dd_(Unix)

We will be using the UNIX utility 'dd' to do this. It can be a VERY dangerous application due to its simplicity. The 'dd' application takes a couple simple arguments: Input, Output, Block Size, and Count (blocks).

1. Download the file in step 2:
2. http://work.mindabuse.net/onmac/pmbr-rescue.bin
3. Plug in either a USB JUMP DRIVE or EXTERNAL HARD DRIVE and copy the above file to it. You CANNOT burn a CD because we need to boot off the installer to perform the rescue.
4. Boot the Mac OS X Installer Disc
5. Open up Disk Utility
6. Identify the internal drive & Unmount all of the partitions on the disk to be rescued
7. 'Get Info' on the disk device itself. Note the 'Disk Identifier', which will be disk#. The partition type should be FDisk_partition_scheme.
8. Quit Disk Utility and open up Terminal.
9. Locate and find the FULL PATH of your external media and the saved pmbr-rescue.bin file. It should be SIMILAR to: /Volumes/USB/pmbr-rescue.bin
10. Back up the MBR of the rdisk# to your external media with the command in step 11. REPLACE rdisk# AND OUTPUT FILEPATH (of=) ACCORDINGLY:
11. dd if=/dev/rdisk# of=/Volumes/USB/mbr-backup.bin bs=512 count=1
12. THE FOLLOWING STEP (step 13) IS GOING TO WRITE APPLES 'PMBR' SECTOR TO THE BEGINNING OF THE HARD DISK. THIS WILL RESTORE MAC OS X's ABILITY TO SEE THE GUID PARTITION SCHEME ON THE PROPER DISK. IF YOU AREN'T SURE IF YOU HAVE THE RIGHT DISK DO NOT CONTINUE. REPLACE rdisk# AND INPUT FILEPATH (if=) ACCORDINGLY:
13. dd if=/Volumes/USB/pmbr-rescue.bin of=/dev/rdisk# bs=512 count=1
13. We will now attempt to read the GUID partition table with step 14:
14. gpt -r show /dev/rdisk#

Hopefully this will be your internal hard drive.

If your output looks SIMILAR to the following than the GUID partition tables are still intact (The important lines are the Pri & Sec GPT headers/tables):

start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 38820536 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
39230176 262144
39492320 38410856 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
77903176 262151
78165327 32 Sec GPT table
78165359 1 Sec GPT header


If you see something similar to the output above then you should be recovered. Quit the Terminal ('exit') and check things out in Disk Utility.

If your output looks like the following than the disk has NO GPT partition.


start size index contents
0 156301488


Again, you DO NOT want to see the output above... If you do then you will most likely want to restore the backup MBR we wrote in step 11 with the following command. THE FOLLOWING COMMAND WILL UNDO EVERYTHING WE'VE ATTEMPTED:

dd if=/Volumes/USB/mbr-backup.bin of=/dev/rdisk# bs=512 count=1

I hope this helps if you were caught in the same bind I was. Good luck.

maconic
20th March 2006, 11:17 AM
Hi!


I don't know how you created that recovery bin file, I just partitioned my usb disk into GPT, made a copy of its first 512 bytes and restored that on my internal MBP drive. (using boot DVD).

The GPT shows up just as it is supposed to in gpt -r show /dev/disk0 but still I can't boot from the drive, only if I use the alt key :(

Strange, isn't it?

BR;
MaC

profetes
20th March 2006, 03:07 PM
Thanks Jerbare, it works wonderfully. You saved my day!
Great solution.

maconic
20th March 2006, 05:10 PM
Hi!

Just to make sure, I also tried the file from this forum, and while my disk shows up as GPT disk in disk utility or in gpt tool, I just can't boot from it.

If I turn on the MBP it just shows the folder with the question mark.
Yet, holding down the alt key DOES show me the internal hdd as bootable and I can also boot into OS X without any issues.

Any ideas?
What exactly does EFI Firmware look for?


BR;
MaC

luckyguy
20th March 2006, 10:29 PM
I can't quite tell if this is recovery of the boot record after dual boot install or reverting back to the original state of pre-dual boot situation. It seems the former, as you mention "after running xom.efi".

I'm trying to verify that I can (and learn how to) restore to the original state of the drive before I do anything. I have a loaner 20" that I would like to return as is (pre-dual boot), including the bootloader.

Thoughts?

Tx

maconic
20th March 2006, 11:46 PM
Well if there is no important data on the machine you always can wipe out everything and start from a clean install.

Even the graphical Disk Utility (which you can start from the installer DVD), does offer you to partition GPT.

As xom.efi does not modify your firmware (its "just" a bootloader for EFI and a normal EFI prog), it should be enough to put back your disk(s).

Nobody should notice a thing later...

BR;
MaC

chiefsalami
21st March 2006, 12:34 AM
Hi!

Just to make sure, I also tried the file from this forum, and while my disk shows up as GPT disk in disk utility or in gpt tool, I just can't boot from it.

If I turn on the MBP it just shows the folder with the question mark.
Yet, holding down the alt key DOES show me the internal hdd as bootable and I can also boot into OS X without any issues.

Any ideas?
What exactly does EFI Firmware look for?


BR;
MaC

I believe (and granted, I am not an expert) that the reason the machine does not boot into OSX but you can see it and boot it if you hold the Alt key is because it is not properly "blessed" and set to be bootable. This is pretty easy to fix. You just need your OSX install disc. Stat up the computer using it, and go to Utilities and launch the Terminal application. Use the following command to bless your OSX installation (where [OSX] is the name of your OSX volume - without brackets): sudo bless --folder /Volumes/[OSX]/System/Library/CoreServices --file boot.efi --setBoot

mcnaugha
21st March 2006, 10:10 AM
I can't seem to get my disk back to GPT using the Disk Utility on either my MacBook Pro or iMac DVDs. See my post on the matter here:

http://forum.onmac.net/showpost.php?p=2215&postcount=3

maconic
21st March 2006, 11:22 AM
No, I have already tried that :(

Its not the blessing, at least not this blessing command :(

BR;

MaC

luckyguy
21st March 2006, 03:03 PM
Well if there is no important data on the machine you always can wipe out everything and start from a clean install.

Even the graphical Disk Utility (which you can start from the installer DVD), does offer you to partition GPT.

As xom.efi does not modify your firmware (its "just" a bootloader for EFI and a normal EFI prog), it should be enough to put back your disk(s).

Nobody should notice a thing later...

Thanks for the info. Tally-ho!!!!

rastaman
22nd March 2006, 12:59 AM
This works well! Many thanks!

apollo_boy
24th March 2006, 03:15 AM
Hi:

I just attempted the PMBR fix that you posted and I've been unsuccessful in restoring the PMBR.

I run the following command:

dd if=/Volumes/STICK/pmbr-rescue.bin of=/dev/rdisk0 bs=512 count=1

and keep getting the error message: "dd /dev/rdisk0 Resource Busy" after running the command stack.

I have verified both the source and target paths as being correct.

Any ideas would be greatly appreciated.

Best Reagards,

Daryl Katauskas

rastaman
24th March 2006, 06:53 AM
Hi Daryl,


I run the following command:

dd if=/Volumes/STICK/pmbr-rescue.bin of=/dev/rdisk0 bs=512 count=1

and keep getting the error message: "dd /dev/rdisk0 Resource Busy" after running the command stack.


Just unmount each volumes located on disk0 before doing the operation. For instance:

umount /Volumes/MacOS && umount /Volumes/NO\ NAME

Issue the mount command to know the slices of the disk0 currently mounted (umount all devices /dev/rdisk0s*).

EDIT: not unmount but umount!

lasvegas
31st March 2006, 06:45 AM
Thank-you, jerbare! That solved the one flaw in my system. I was concerned about any upcoming upgrade (10.5) not liking the partition scheme. The 'xom.efi' should be patched to perform this fix, if needed. At the very least, this should be added to the end of the Install HOWTO.

BTW: For those that are having trouble after messing up the partitions (Not following the HOWTO to the letter). To reformat the drive to GUID using Disk Utility on the Boot DVD. Select the drive and Erase (Not Partition!) the entire drive. This will restore the GUID partitioning scheme. You can now go to the Partition section and create your two partitions in the GUID scheme.

lasvegas
31st March 2006, 08:11 PM
Woops! Jumped the gun! After making the fix, my Windows partition wiped itself! Is this normal? I went through the setup and install again, but am afraid to try this fix again. Can anyone verify if my experience is unique and assure me that it's safe to try again?

Thanks,

LasVegas

jerbare
6th April 2006, 12:46 AM
ATTENTION:

If you cannot update the firmware and want to try keeping your existing XOM Windows installation to use Boot Camp follow my original instructions...

I haven't personally tested that this method works yet (waiting on backups - VERY important!), but I have heard several reports of people having success with restoring the PMBR to get the firmware update to complete successfully...

The reason it is failing in the first place is because the updater does not recognize the EFI partition with the FDISK partition scheme. The EFI partition is used for the firmware update process...

Restoring the PMBR will restore your Mac's partition scheme to its pre-XOM state. All of your partitions should remain intact, including your Windows partition...

rxcited
6th April 2006, 04:05 AM
Jerbare, thanks for the possible fix. I just tried the Apple firmware update and it failed. I do have XOM installed and working. The thing is, my partition scheme seems to be different than most. Here is what I get from diskutil:
$ diskutil list
/dev/disk0
#: type name size identifier
0: FDisk_partition_scheme *93.2 GB disk0
1: Windows_FAT_32 WINDOWS XP 32.0 GB disk0s1
2: Apple_HFS Macintosh HD 61.2 GB disk0s2
I don't have the 200 Mb (unused?) EFI parition like the instructions show and others have listed. I can't explain why mine turned out differently but when I went to install XP, it said it could not install onto the FAT partition I had created for XP. So I told it to delete the partition and install into the empty space. I ended up with what you see above and a perfectly working XOM setup.

The question is, should I attempt your procedure above, or will it just trash my disk since I don't have the correct partition scheme?

skehlet
6th April 2006, 04:33 AM
Thank you Jerbare! dd'ing in your pmbr worked for me. Also, while I was booted off the Mac OS install DVD I gpt remove'd the FAT partition. man gpt for folks looking to do the same.

Saved me re-installing OS X!

actionperformed
6th April 2006, 07:04 AM
Just to Confirm , This works well. I just finished Updating the new firmware. I use a MBP.

I need to this because 1) I don't want to reinstall everything (not even xp). 2). of course I want the drivers to work.

Anybody done it this way? Should I rebless the xom.efi now ? or now, that I've updated the firmware, I should change the pmbr to mbr?

Please share your experience. But nonetheless, this method let you successfully update firmware. I'm not particularly good with unix, but as long as you follow the steps and type in those command carefully. It's easy!

Thanks alot.

actionperformed
6th April 2006, 07:35 AM
Here is an update.

After I update the firmware. re-blessed the xom.efi file. I cannot boot to windows. (upside down windows logo at start). DiskUtility shows only the os x partition. But in OSX, the xp drive is mounted and accessiable.

I boot the OS X disk, 'diskutil list' command shows only the apple partition. using the terminal to dd back the mbr-backup.bin on my usb drive. 'diskutil list' shows xp partition , everything seems normal before following this fix.

Boot windows xp (xom.efi).. ... No luck!

Going into disk utility in OSX, disk0s2(xp ) is partitioned , formatted but not mounted.
I will just pack my bag and join the boot camp, i guess. This already saved me tons of time backup osx and restore the system.

rxcited
6th April 2006, 09:45 PM
Jerbare, thanks for the possible fix. I just tried the Apple firmware update and it failed. I do have XOM installed and working. The thing is, my partition scheme seems to be different than most. Here is what I get from diskutil:
$ diskutil list
/dev/disk0
#: type name size identifier
0: FDisk_partition_scheme *93.2 GB disk0
1: Windows_FAT_32 WINDOWS XP 32.0 GB disk0s1
2: Apple_HFS Macintosh HD 61.2 GB disk0s2 I don't have the 200 Mb (unused?) EFI parition like the instructions show and others have listed. I can't explain why mine turned out differently but when I went to install XP, it said it could not install onto the FAT partition I had created for XP. So I told it to delete the partition and install into the empty space. I ended up with what you see above and a perfectly working XOM setup.

The question is, should I attempt your procedure above, or will it just trash my disk since I don't have the correct partition scheme? After making complete backup images of both my OS X and XP volumes with Disk Utility stored on an external USB drive, I gave the dd commands a whirl. It did not work for me; I got a listing similar to the second one with just a couple lines. I guess my setup was never going to work for the Apple GPT requirement for firmware updates.

So erased my drive and created one HFS+ volume. I started as if I were going to do a fresh OS X installation to make sure it would recognize the volume. Once it looked okay, I backed out of it and I am blowing my OS X image back onto it now using Disk Utility. Assuming I can boot OS X (already updated to 10.4.6 before backing up), I will try the firmware update again, then run Boot Camp to create the FAT32 partition. Then I will use Disk Utitilty again to restore my XP image onto this parition to see if I can get back close to where I was with XOM before BC came out. Then I will run the Apple BC drivers install under XP and see if I am OK. Jeeze...:rolleyes:

rxcited
11th April 2006, 08:04 AM
Maybe the last post in this thread? I wanted to reuse my OS X and XP installations, but my partition scheme was screwed and I could not install the firmware update. After all said and done, I was able to salvage both my OS X and XP installations for use in Boot Camp using save/restore from Disk Utility. See this post for details including some boot.ini issues I resolved: :eek:

http://forum.onmac.net/showpost.php?p=6428&postcount=4

Prokium
27th April 2006, 05:58 PM
Hello guys,

i have a big big problem, and i don't even have a backup unfortunatly ;(
like lot of people here i installed XOM and i wanted to replace XOM with BootCamp, then i followed the HOWTO : http://wiki.onmac.net/index.php/Replacing_XOM_With_Boot_Camp
from Nevyn.

everything goes OK,
after installing the new firmware, i installed BootCamp and i ran BootCamp and clicked "install windows" or something like that, bootcamp rebooted my macbook pro and from there, i see a DOS message that tell i don't have any operating system please put a bootable cd and press a key or something like that.

After i read your howto, and i seen that i had to recover the partition schema before runing bootcamp, i didn't made that !!
i'm totaly stuck now, i didn't touch anything to be sure to not destroy more my datas, and try to find any solution to be able to restore my partition schema,
also i saved the original partition schema (like the howto tell to do) on a text file but its on the desktop !!!, but as i cannot boot on OSX anymore,
i cannot even get my original partition schema.
i have a 80giga hard-drive, 10gig was for winXP (using the XOM) and the rest for OSX...

do you have a solution for me pease ??

i was thinking of a recover tool that just restore the partition schema from an hard drive, or i don't , maybe a way to be able to run fdisk from a bootable device to be able to recover the original schema ???

it is very annoying as i have lot of very important data and i didn't made a backup ...


thank you , if someone can help me . i will really be happy

/yaniv

philoin
17th October 2006, 04:04 PM
Hi,
I tried to install Fedora Core 5 as the third boot on my iMac Intel coreduo and guess what:my Boot Camp dual boot (OSX/XP) has gone...
This thread could be very helpfull for me except I can't download neither find the pmbr-rescue.bin file.
Is somebody aware of what happen with this file ? Maybee we can find it somewhere. Or with an other name. I had no success digging on any search engine to find it.

Thanks to you all.

space ace
8th December 2006, 11:34 AM
Hi,
I tried to install Fedora Core 5 as the third boot on my iMac Intel coreduo and guess what:my Boot Camp dual boot (OSX/XP) has gone...
This thread could be very helpfull for me except I can't download neither find the pmbr-rescue.bin file.
Is somebody aware of what happen with this file ? Maybee we can find it somewhere. Or with an other name. I had no success digging on any search engine to find it.

Thanks to you all.

hi, i also missed the file but managed without it. just like the second poster said, you can create one off the guid-formatted usb stick. it worked, amazingly! :) good luck.

colzhao
17th December 2006, 09:30 AM
Hi there,

Does anyone have a copy of pmbr-rescue.bin? I can't seem to download it and my mac is very very dead!

Thanks!

Col