Increasing Mac partition after shrink Windows Bootcamp partition

5,471

I'm pretty sure you've created a highly dangerous and inconsistent layout.

The problem is this: Macs that dual-boot with Windows generally use a hybrid MBR, which is a way to get two partition tables to (sort-of) coexist on a disk. The GUID Partition Table (GPT) is the authoritative partition table and is the one that MUST be modified by any tool that resizes partitions. In a hybrid MBR setup, one or more normally-empty fields in the Master Boot Record (MBR) are employed to replicate data in the GPT data structures. When confronted with a hybrid MBR disk, OS X uses the GPT data, whereas Windows uses the MBR data. A hybrid MBR is also used as a signal to the Mac's firmware that the disk may be booted in BIOS mode (vs. the EFI mode that OS X uses).

The trouble with this is that if you use a GPT-unaware tool to resize, move, or create partitions, you'll be changing the unauthoritative MBR data structures while not changing the authoritative GPT data structures. That's sort of like entering a deposit in your checkbook without actually depositing a check -- it may look cool to have $1,000,000 in your bank account, but if you try to use the money, you'll be in trouble! This is (I think) what you've done -- by changing the MBR data structures, you've created a partition that Windows can use but that OS X can't. Worse, depending on the details of what you've done, you may be damaging one OS's files whenever you write information in the other OS.

To recover, I recommend that you first back up everything to another disk.

With that done, you can attempt a data recovery by examining the start and end points of both the GPT and MBR data. You can do this with gdisk -- an ordinary p command displays the GPT data; and in the experts' menu or the recovery menu, an o command displays the MBR data. (Ignore the type-0xEE MBR partition; that signals that the disk is a GPT disk, nothing more.) Figure out which partitions match and which don't. Make note of which partition(s) you use from OS X, and which you use from Windows. The Windows partitions will be on the MBR side. Once you've figured out which partitions you're using, delete the non-functional GPT partitions and, in their place, create new partitions with the same start and end points as the MBR partitions that work in Windows. This procedure assumes that you can actually create these partitions; if they overlap, you're in deep trouble and you'll really have to delete all the overlapping partitions, create new ones, and restore everything from your backups. Once you've done all this, you can create a new hybrid MBR, as described on my Web page.

In the future, be sure to obey Rule #1 for hybrid MBRs:

NEVER, EVER USE GPT-UNAWARE UTILITIES ON A HYBRID MBR DISK!

In some cases, you'll need to modify the GPT data structures with a GPT-only tool and then create a new hybrid MBR to reflect the changes.

Share:
5,471

Related videos on Youtube

javsmo
Author by

javsmo

Updated on September 18, 2022

Comments

  • javsmo
    javsmo over 1 year

    I have a Mid 2010 Macbook Pro running Mac OS X 10.9.4 with a 500GB HD.

    The HD is partitioned with 370 GB to Mac and 128 GB to Windows and I decided to shrink the Windows partition to 65 GB because I needed more space on Mac, and I barely use Windows.

    I resized the Windows Partition using Mini Tool Partition Wizard and moved it to the end of the disk, leaving the empty right after Mac partition.

    I'm able to boot Windows partition and use it normally. The Windows C: disk now has 65 GB.

    When I boot on Mac OS X and try to use disk utility to increase the Mac partition, it says that the Windows partition still has 128 GB.

    It is possible to use the empty space I created?

    Here's some information about my partitions:

    $ sudo gpt -r -vv show disk0
    gpt show: disk0: mediasize=500107862016; sectorsize=512; blocks=976773168
    gpt show: disk0: Suspicious MBR at sector 0
    gpt show: disk0: Pri GPT at sector 1
    gpt show: disk0: Sec GPT at sector 976773167
          start       size  index  contents
              0          1         MBR
              1          1         Pri GPT header
              2         32         Pri GPT table
             34          6        
             40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
         409640  723603632      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
      724013272    1269544      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
      725282816  251490304      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
      976773120         15        
      976773135         32         Sec GPT table
      976773167          1         Sec GPT header
    
    $ sudo gdisk /dev/disk0
    GPT fdisk (gdisk) version 0.8.10
    
    Warning: Devices opened with shared lock will not have their
    partition table automatically reloaded!
    Partition table scan:
      MBR: hybrid
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with hybrid MBR; using GPT.
    
    Command (? for help): p
    Disk /dev/disk0: 976773168 sectors, 465.8 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): E34EA0BB-B94A-4854-AF05-02E0D06A48E5
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 976773134
    Partitions will be aligned on 8-sector boundaries
    Total free space is 21 sectors (10.5 KiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1              40          409639   200.0 MiB   EF00  EFI System Partition
       2          409640       724013271   345.0 GiB   AF00  Macbook HD
       3       724013272       725282815   619.9 MiB   AB00  Recovery HD
       4       725282816       976773119   119.9 GiB   0700  BOOTCAMP
    
    
    $ sudo fdisk /dev/disk0
    Disk: /dev/disk0 geometry: 60801/255/63 [976773168 sectors]
    Signature: 0xAA55
             Starting       Ending
    #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
    ------------------------------------------------------------------------
    1: EE 1023 254  63 - 1023 254  63 [         1 -     409639] <Unknown ID>
    2: AF 1023 254  63 - 1023 254  63 [    409640 -  723603632] HFS+       
    3: AB 1023 254  63 - 1023 254  63 [ 724013272 -    1269544] Darwin Boot
    4: 0C 1023 254  63 - 1023 254  63 [ 725282816 -  251490304] Win95 FAT32L
    

    EDIT:

    After trying another solution I can't boot on my Windows partition anymore. The partition information is the same above.

    • Osa
      Osa almost 9 years
      Have you found a solution for this ? I'm trying to search but no luck..
    • javsmo
      javsmo almost 9 years
      Unfortunately, there's no way to do this because, as I said on a comment of @Tesujin's answer, Windows cannot handle more than 4 partitions on a disk.
  • javsmo
    javsmo over 9 years
    I think it is a little bit expensive to me. I'm not saying that it's not worth it, but I'd like to do the partitioning without spending almost $60.00 (£ 36.00). Another disadvantage is that, as its FAQ says, after you resize a Windows Partition with iPartition, you can't use another Windows disk program to manipulate the disks anymore.
  • javsmo
    javsmo over 9 years
    One problem I discovered is that Windows cannot handle more than 4 partitions on a disk. I have 4 partitions already. I don't know if I had only 3 I would be able to resize it and leave an empty space to MacOS X grow its partition.
  • javsmo
    javsmo almost 9 years
    I appreciate your effort in answering, but you gave a good explanation on how to recover and what I did wrong, but not how to use the empty space, which I think is not possible due to the Windows Restriction on having at most 4 partitions. I already recovered all partitions, but still would like to resize the windows partition to reduce its size. Anyway thanks for your answer.
  • Rod Smith
    Rod Smith almost 9 years
    There is no Windows restriction limiting you to four partitions. That's a limit of the MBR partitioning scheme. Your disk is GPT with a hybrid MBR, which means you can have up to 128 partitions by default, but only three can be available to Windows. (3 = 4 minus the type-0xEE protective partition.) You can select any three GPT partitions to be mirrored as Windows partitions if you use gdisk to create (or re-create) your hybrid MBR. To use unpartitioned space, use a GPT partitioning tool. If you want to use it in Windows, add that GPT partition to your hybrid MBR.
  • javsmo
    javsmo almost 9 years
    If I need to reinstall Windows, I'll just delete the partition and use the entire disk with Mac OS X. Do you know any tool that can make this resize without reinstalling Windows?
  • Rod Smith
    Rod Smith almost 9 years
    Step 1: Back up everything. Step 2: Resize the partition with a GPT-aware tool. Step 3: Re-create the hybrid MBR with gdisk, gptsync, or some other tool. Step 2 can be done with GParted in Linux. (Use a Linux emergency disk, such as the Ubuntu installer in its "try before installing" mode.) I don't know offhand if the OS X Disk Utility can resize NTFS partitions, or if any third-party OS X utilities can do it. (My hunch is that something can, but I don't know that for certain.)
  • javsmo
    javsmo almost 9 years
    I have Time Machine with everything I need. If I loose the Windows partition, I won't loose anything important. So, the backup part is continuously done (it's doing right now, for example). Maybe the Ubuntu installer do the trick. The OS X Disk Utilities can't resize NTFS without deleting it, unfortunately.