Some time ago, I used BootCamp to set up a partition for Windows 7 on my MacBook Pro (13" late 2014 if it matters) so I could dual-boot. I have since removed the partition using BootCamp, but still can't reclaim the disk space.

The new Disk Utility doesn't show the partition (I'm using the 10.11 Public Beta, but have also checked in the Recovery partition which is still using the old Yosemite Disk Utility).

However, the diskutil Terminal command shows this:

cwatson@ragnarok:~$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            398.6 GB   disk0s2
   3:                 Apple_Boot Recovery HD             101.5 GB   disk0s3

It seems the resize has screwed up somewhere, and made the Recover HD over 100GB.

cwatson@ragnarok:~$ sudo gpt -r show /dev/disk0
      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  778422104      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  778831744  198273280      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  977105024          3
  977105027         32         Sec GPT table
  977105059          1         Sec GPT header

Is there any way of (safely) resizing this back down to something sensible, so I can reclaim the space?

  • Please add the output of sudo gpt -r show /dev/disk0 entered in Terminal.app to your question. Is it still possible to boot (alt-R while booting) from the Recovery volume or is it corrupted? – klanomath Jul 30 '15 at 19:34
  • @klanomath Thanks, question edited. Recovery partition is still bootable. – Craig Watson Jul 30 '15 at 20:07

If it hadn't been 10.11 Public Beta (2) on the main volume, I would have advised to boot to Internet Recovery Mode (IRM) (altcmdR) or a bootable thumb drive (BTD), just delete the 3rd partition with gpt remove -i 3 /dev/disk0 and fully expand the main partition with Disk Utility. After rebooting to the main volume I would have reinstalled the latest OS X (Yosemite 10.10.4 as of this writing) which recreates the Recovery HD while preserving all non-Apple apps and user-created data.

Instead you have to dd the Recovery HD from a second Mac running Yosemite. Copy the resulting file to the first Mac. Then boot Mac1 to IRM/BTD, delete the 3rd partition with gpt, reboot to IRM/BTD, resize the main volume with diskutil resizeVolume /dev/disk0s2 size, create a 3rd partition with:

 gpt add -b first_freeblock -i 3 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0

and finally dd the previously made copy of Recovery HD (Mac2) back to /dev/dis0s3.

To get size in diskutil ... size you have to do some math considering that the last blocks of a Yosemite drive containing the Recovery HD usually look like this:

....                      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
975503592    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
976773128          7         
976773135         32         Sec GPT table
976773167          1         Sec GPT header

Recheck this with sudo gpt -r show /dev/disk0 on Mac2.
The example here is a 500.1 GiB (976773168 blocks à 512 B) disk.

Accordingly "size" has to be smaller than or the same size as (total blocks - 409640 - 1269576 blocks). The second term is block0 - block409639 containing PMBR, the primary GPT header and table and the EFI partition. The third term is the size of the Recovery HD and the secondary GPT header and table. Please consider that block counting starts with 0: block 0 is the the first block or block 975503592 is the 975503593rd block.

If you are to lazy to do the math, you may first create the third partition and dd the Recovery HD file and then - after a restart - expand the main volume using Disk Utility.

A second more risky method (not risky regarding your data on the main volume but I'm not sure if it is successful) is just moving the partition borders of disk0s3. This method presumes that no files of the old Recovery HD were moved "physically" on disk0s3 after deleting the Boot Camp partition with the Boot Camp assistant.

Boot to IRM/BTD and enter in Terminal:

gpt remove -i 3 /dev/disk0

and reboot to IRM/BTD. Then add a third partition with the following command (already adapted to the size of your disk!):

gpt add -b 975835488 -i 3 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0

and reboot to IRM/BTD. Open Disk Utility and verify/repair the hard drive (and not the main volume!). Then enlarge the main volume to max size and verify /repair the main volume. Finally try to boot to Recovery Mode (cmdR).

  • If you don't have a second system to get a copy of the Recovery HD from, I've installed OS X in a virtual machine and gotten a copy of the Recovery HD that way. – user3439894 Jul 30 '15 at 23:07


Prepare a USB disk,

diskutil erasedisk jhfs+ Make_Recovery disk3
sudo asr restore --source /Volumes/Recovery HD/com.apple.recovery.boot/BaseSystem.dmg --target /dev/disk0s3 --erase
sudo asr adjust --target /dev/disk3s2 --settype Apple_Boot`

then delete Recovery HD partition.

Besides, you can backup BaseSystem.dmg, and restore to new partition.

  • Doesn't answer the question - the question was specifically looking for destructive answers. – Craig Watson Sep 14 '16 at 12:50
  • I think it is a normal situation after delete windows partition in bootcamp. – netawater Sep 20 '16 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .