Ulrik N

Q: Upgrading to Mavericks, MBR partition scheme?

When trying to upgrade my Mac OSX Lion to Maverick i discovered that the disk0 partition was marked as MBR.
Mavericks requires a GUID partition format.
So i need a way to convert disk0 from MBR to GUID ( GPT ) format.

 

The following is information from fdisk, gdisk and disk utility, about my disk configuration:

 

From Mac Disk Utility:

Name : APPLE SSD TS256C Media

          Type :           Disk

 

          Partition Map Scheme :           Master Boot Record

          Disk Identifier :           disk0

          Media Name :           APPLE SSD TS256C Media

          Media Type :           Generic

          Connection Bus :           SATA

          Device Tree :           IODeviceTree:/PCI0@0/SATA@1F,2/PRT0@0/PMP@0

          Writable :           Yes

          Ejectable :           No

          Location :           Internal

          Solid State Disk :           Yes

          Total Capacity :           251 GB (251,000,193,024 Bytes)

          Disk Number :           0

          Partition Number :           0

          S.M.A.R.T. Status :           Verified

          Raw Read Error :           000000000000

          Reallocated Sector Count :           000000000000

          Power On Hours :           00000000224D

          Power Cycle :           000000000A96

          Temperature :           003A000A001F

          UDMA CRC Error (PATA only) :           000000000000

 

$ sudo gpt -r -vv show /dev/rdisk0

Password:

gpt show: /dev/rdisk0: mediasize=251000193024; sectorsize=512; blocks=490234752

gpt show: /dev/rdisk0: MBR at sector 0

gpt show: /dev/rdisk0: MBR at sector 264972225

gpt show: /dev/rdisk0: Pri GPT at sector 1

gpt show: error: bogus map

gpt show: unable to open device '/dev/rdisk0': Undefined error: 0

 

--------------------------------------------------------------

 

$ sudo gdisk -l /dev/rdisk0

Password:

GPT fdisk (gdisk) version 0.8.8

 

 

Warning: Devices opened with shared lock will not have their

partition table automatically reloaded!

Partition table scan:

  MBR: MBR only

  BSD: not present

  APM: not present

  GPT: present

 

 

Found valid MBR and GPT. Which do you want to use?

1 - MBR

2 - GPT

3 - Create blank GPT

 

 

Your answer: 1

Disk /dev/rdisk0: 490234752 sectors, 233.8 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): A80B0E7C-9DBD-4222-9BD5-17823735BFAB

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 490234718

Partitions will be aligned on 8-sector boundaries

Total free space is 1103653 sectors (538.9 MiB)

 

 

Number  Start (sector)    End (sector)  Size       Code  Name

   1          409640       200019007   95.2 GiB    AF00  Apple HFS/HFS+

   2       200710144       264970239   30.6 GiB    0700  Microsoft basic data

   4       293642240       490233855   93.7 GiB    0700  Microsoft basic data

   5       264972288       293642239   13.7 GiB    0700  Microsoft basic data

 

----------------------------------------------------------

 

$ sudo gdisk -l /dev/rdisk0

GPT fdisk (gdisk) version 0.8.8

 

 

Warning: Devices opened with shared lock will not have their

partition table automatically reloaded!

Partition table scan:

  MBR: MBR only

  BSD: not present

  APM: not present

  GPT: present

 

 

Found valid MBR and GPT. Which do you want to use?

1 - MBR

2 - GPT

3 - Create blank GPT

 

 

Your answer: 2

Using GPT and creating fresh protective MBR.

Disk /dev/rdisk0: 490234752 sectors, 233.8 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): 00002069-31E3-0000-9669-00000C420000

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 490234718

Partitions will be aligned on 8-sector boundaries

Total free space is 263973 sectors (128.9 MiB)

 

 

Number  Start (sector)    End (sector)  Size       Code  Name

   1              40          409639   200.0 MiB   EF00  EFI system partition

   2          409640       200019007   95.2 GiB    AF00  Customer

   3       200282112       222867455   10.8 GiB    0700  FREE

   4       222867456       293642239   33.7 GiB    0700  Untitled

   5       293642240       490233855   93.7 GiB    0700  BOOTCAMP

 

----------------------------------------------------------

 

$ sudo fdisk /dev/rdisk0

Disk: /dev/rdisk0          geometry: 30515/255/63 [490234752 sectors]

Signature: 0xAA55

         Starting       Ending

#: id  cyl  hd sec -  cyl  hd sec [     start -       size]

------------------------------------------------------------------------

1: AF   25 127  15 - 1023 254  63 [    409640 -  199609368] HFS+

2: 0B 1023 254  63 - 1023 254  63 [ 200710144 -   64260096] Win95 FAT-32

3: 0F 1023 254  63 - 1023 254  63 [ 264972225 -   28670015] Extended LBA

*4: 07 1023 254  63 - 1023 254  63 [ 293642240 -  196591616] HPFS/QNX/AUX

Signature: 0xAA55

         Starting       Ending

#: id  cyl  hd sec -  cyl  hd sec [     start -       size]

------------------------------------------------------------------------

1: 07 1023 254  63 - 1023 254  63 [ 264972288 -   28669952] HPFS/QNX/AUX

2: 00    0   0   0 -    0   0   0 [         0 -          0] unused

3: 00    0   0   0 -    0   0   0 [         0 -          0] unused

4: 00    0   0   0 -    0   0   0 [         0 -          0] unused

 

----------------------------------------------------------

 


 

Thanks Christopher and Loner for being helpful and looking into this.

 


MacBook Pro (17-inch Early 2011), OS X Mavericks (10.9)

Posted on Dec 16, 2013 2:47 AM

Close

Q: Upgrading to Mavericks, MBR partition scheme?

  • All replies
  • Helpful answers

  • by Loner T,

    Loner T Loner T Dec 16, 2013 2:11 PM in response to Ulrik N
    Level 7 (24,800 points)
    Safari
    Dec 16, 2013 2:11 PM in response to Ulrik N

    From my perspective, arranging the gdisk output using MBR vs GPT (in ascending order of Start/End addresses),

     

    MBR:

     

       1            409640       200019007   95.2 GiB    AF00  Apple HFS/HFS+

     

       2       200710144       264970239   30.6 GiB    0700  Microsoft basic data

       5       264972288       293642239   13.7 GiB    0700  Microsoft basic data

     

       4       293642240       490233855   93.7 GiB    0700  Microsoft basic data

     

    GPT:

     

       1              40          409639   200.0 MiB   EF00  EFI system partition

       2          409640       200019007   95.2 GiB    AF00  Customer

     

       3       200282112       222867455   10.8 GiB    0700  FREE

       4       222867456       293642239   33.7 GiB    0700  Untitled

     

     

       5       293642240       490233855   93.7 GiB    0700  BOOTCAMP

     

    Laying it out this way, I would consider that disk is GPT. In Windows and/or OS X, partitioning work and/or resizing of partitions is the suspect event.

     

    If you are booted into windows, is there any useful data in drives other than C: or the OS X volume? Apple HFS drivers should mount the OS X volume read-only on the Windows side.

  • by Number88,

    Number88 Number88 Dec 16, 2013 3:07 PM in response to Ulrik N
    Level 3 (750 points)
    Dec 16, 2013 3:07 PM in response to Ulrik N

    It seems that your EFI partition is not included in your MBR. This might be tricking the system into thinking you have a MBR only disk (as it's not detecting the EFI partition).

    The GPT seems a bit dodgy too.

     

    What is in the 3 Microsoft partitions?

  • by Ulrik N,

    Ulrik N Ulrik N Dec 17, 2013 7:39 AM in response to Loner T
    Level 1 (4 points)
    Desktops
    Dec 17, 2013 7:39 AM in response to Loner T

    Loner T wrote:


    In Windows and/or OS X, partitioning work and/or resizing of partitions is the suspect event.

     

    That is probably what has happened.

    I remember resizing my partitions with Patition Commander and the later rebuilding the MBR with MiniTool Partition.

     

     

    Loner T wrote:

     

    If you are booted into windows, is there any useful data in drives other than C: or the OS X volume? Apple HFS drivers should mount the OS X volume read-only on the Windows side.

     

    I have a partition for shared files and cross platform development projects, Eclipse, HTML, etc.
    And second partition for backup files.

    The third partition is used for the Windows 7 OS.

  • by Loner T,

    Loner T Loner T Dec 17, 2013 9:46 AM in response to Ulrik N
    Level 7 (24,800 points)
    Safari
    Dec 17, 2013 9:46 AM in response to Ulrik N

    Thanks for the clarification.

     

    Bootcamp drives typically support four partitions - EFI, OS X, Recovery HD, and Bootcamp.

     

    Your fdisk MBR and GPT do not agree either (as shown by start/end addresses).

     

    One suggestion would be to backup both the "Shared" and "Backup" partitions, delete them from both GPT and MBR, and re-create the GPT partitions with correct start/end addresses, and create a hybrid MBR via gdisk.

     

    This, as Christopher says, would still be fragile, till Macs start supporting the newer UEFI and then the MBR is no longer required and Windows and OS X and additional partitions can co-exist happily via just GPT.

  • by Christopher Murphy,

    Christopher Murphy Christopher Murphy Dec 25, 2013 9:38 AM in response to Ulrik N
    Level 3 (555 points)
    Dec 25, 2013 9:38 AM in response to Ulrik N

    I'm confused by the message "gpt show: unable to open device '/dev/rdisk0': Undefined error: 0" for the gpt command, and "Warning: Devices opened with shared lock will not have their partition table automatically reloaded! for the gdisk command. I don't get these on 10.8.5, is that what you're using?

     

    The thing both gpt and gdisk seem to indicate is that the disk has a stale GPT, and both tools consider it as being MBR. However the firmware and kernel must be treating it as GPT or else OS X wouldn't boot, given the fdisk result with a single partition entry for Windows.

     

    I'm willing to bet the MBR Windows entry is correct, while the gdisk reported GPT entries are correct for partitions 1 and 2 at least. Maybe also 3 and 4 are reliable, but partition 5 is probably unreliable. Since they're all posted, you essentially have a backup of all available information at this point.

     

    The first step is to make this a GPT disk once again, which gdisk does when you choose option 2 to use GPT. At that point, p shows you the GPT with the likely wrong entry 5. I'd delete that entry, with d<enter>5<enter>. Then add new, n, and accept default of 5 with just <enter>, start value 264972288, and the end value 293642239 (this is computed by using the fdisk entry start value, plus size value, minus 1). Then go to the recovery menu, r, create new hybrid mbr, h, and follow that interactive sequence. Not in order, but from my memory, you want the EFI GPT included as entry 1 in the MBR, you want to add partitions 3 4 5 to the MBR. You'll accept their default type code of 07 by just using enter. And you only want 5 marked bootable, so you'll say n for the others and y for 5. Then w to write all of this out to disk. And see if you can boot both OS X and Windows as a first test so you can at least get backups of your data.

     

    The loose ends: I don't know what partitions 3 and 4 are about, I'm assuming they're extra partitions for Windows for some reason. Since there isn't enough room in the MBR for your OS X partition, it will not be visible in Windows. This can be changed but then you'd have to drop either partition 3 or 4 which isn't advised because it creates a layout that can't protect everything in both partition maps. It would expose either partition 3 or 4 as "free space" from the perspective of Windows. And also this system lacks a Recovery HD, so either it was deleted or possibly this is a 10.6 system?

     

    In any case, because the GPT has more than 4 entries, upon upgrading to Mavericks, it will blow away the hybrid MBR you create above, and Windows will once again no longer be bootable. So you'll have to create a new hybrid MBR again. The only way to prevent a future Apple upgrade (maybe even an update) or Disk Utility from causing problems is to return the disk to having only four partitions: EFI System, OS X, Recovery HD, Windows.

  • by Ulrik N,

    Ulrik N Ulrik N Dec 27, 2013 10:50 AM in response to Christopher Murphy
    Level 1 (4 points)
    Desktops
    Dec 27, 2013 10:50 AM in response to Christopher Murphy

    Christopher Murphy wrote:

     

    I'm confused by the message "gpt show: unable to open device '/dev/rdisk0': Undefined error: 0" for the gpt command, and "Warning: Devices opened with shared lock will not have their partition table automatically reloaded! for the gdisk command. I don't get these on 10.8.5, is that what you're using?

    17-inch, Early 2011

    Software  Mac OS X Lion 10.7.5 (11G63b)