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).

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?
– klanomathJul 30 '15 at 19:34

2 Answers
2

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:

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!):

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).