Fixing Apple_partition_map bug from OS X

Dan Burcaw yellowdog-general@lists.terrasoftsolutions.com
Thu May 22 00:40:01 2003


I have compiled a version of 'pdisk' for OS X allowing the repair of the
Apple_partition_map bug.  Since this bug prevents OS X booting to begin
with, the following assumes you have found another way into OS X. For 
instance, via BootCD (www.charlessoft.com) or installing another OS X
system on another drive.

Before proceeding, you need to download the 'pdisk' version compiled for OS X.
It is located at: http://stage.terraplex.com/~dburcaw/pdisk_OSX.gz

After it is downloaded, move the file to the top level of your OS X Home
directory.  The following instructions are to be followed from the Mac OS X
"Terminal" application located in Applications -> Utilities.


1) Ungzip, give execute permissions, and run pdisk_OSX with root privledges.

  [Dan-Burcaws-Computer:~] dburcaw% gunzip pdisk_OSX.gz
  [Dan-Burcaws-Computer:~] dburcaw% chmod 755 pdisk_OSX
  [Dan-Burcaws-Computer:~] dburcaw% sudo ./pdisk_OSX
  Password:
  Top level command (? for help):


2) Find out which drive has partition 1 incorrectly labeled "Apple_Bootstrap"
   instead of "Apple_partition_map" by typing "L" at the pdisk prompt.

  Top level command (? for help): L
  /dev/rdisk0  map block size=512
     #:                 type name                  length   base      ( size )
     1:      Apple_Bootstrap Apple                     63 @ 1        
     2:      Apple_UNIX_SVR2 untitled           156355500 @ 64        ( 74.6G)
     3:           Apple_Free Extra                     20 @ 156355564

  Device block size=512, Number of Blocks=156355584
  DeviceType=0x0, DeviceId=0x0

  pdisk: can't open file '/dev/rdisk1'  (No such file or directory)
  pdisk: can't open file '/dev/rdisk2'  (No such file or directory)
  pdisk: can't open file '/dev/rdisk3'  (No such file or directory)
  pdisk: can't open file '/dev/rdisk4'  (No such file or directory)
  pdisk: can't open file '/dev/rdisk5'  (No such file or directory)
  pdisk: can't open file '/dev/rdisk6'  (No such file or directory)

In my case, only /dev/rdisk0 is present, and it does have the problem
since partition #1 has an incorrect type of "Apple_Bootstrap". 


3) Edit the drive with problem by typing "e" at pdisk prompt. After that,
specify the drive that is incorrectly labeled. In my case, this is /dev/rdisk0.
(the device for the problem drive was determined in step 2)

  Top level command (? for help): e
  Name of device: /dev/rdisk0


4) Change the type of partition #1 to "Apple_partition_map" by typing "t"
at the pdisk prompt.  When prompted for partition type, enter "Apple_partition_map"
without quotes, precisely as indicated.

  Command (? for help): t
  Partition number: 1
  New partition type: Apple_partition_map


5) Print the map to verify that partition #1 no longer has the incorrect type
"Apple_Bootstrap" but now has the type "Apple_partition_map".  Do this by typing
"p" at the pdisk prompt.  If everything looks good, proceed to the next step.
Otherwise, go back and make sure you have done everything correctly.

  Command (? for help): p
  /dev/rdisk0  map block size=512
     #:                 type name                  length   base      ( size )
     1:  Apple_partition_map Apple                     63 @ 1        
     2:      Apple_UNIX_SVR2 untitled           156355500 @ 64        ( 74.6G)
     3:           Apple_Free Extra                     20 @ 156355564

  Device block size=512, Number of Blocks=156355584
  DeviceType=0x0, DeviceId=0x0


6) If everything looks good in the previous step, write the changes via
the "w" command at the pdisk prompt.

  Command (? for help): w
  Writing the map destroys what was there before. Is that okay? [n/y]: y
  The partition table has been altered!


7) Quit editing current disk by typing "q" at pdisk prompt.

  Command (? for help): q


8) If another drive was listed in step #2 with partition 1 as type
"Apple_Bootstrap" and not "Apple_partition_map", go back to step #3
and repeat the steps to fix that drive as well.  Otherwise, skip
this step and go to step 9.


9) Quit pdisk by typing "q" at the prompt.

  Top level command (? for help): q
  The end
  [Dan-Burcaws-Computer:~] dburcaw% 


10) Verify that OS X now boots properly.