How do I regain unaccessible free space after a failed Boot Camp install on a non-Fusion drive?

Solution 1:

This should be one way to regain your unused space. There might be a better (or more elegant) solution, but since i don't have a spare Mac at the moment (and it doesn't work in a virtual environment) i can't figure that out.

The solution outlined here removes any partition which obstructs the expansion of the CoreStorage Volume Group. Then the physical (CoreStorage) volume and afterwards the logical (CoreStorage) volume will be expanded non-destructively to almost full size. At the end the Recovery HD deleted previously will be restored by reinstalling the current system.

Initial state (disk0 is your physical device and disk1 is a "virtual" CoreStorage device - the disk identifier may vary depending on your setup):

enter image description here

Final state:

enter image description here

Preparation:

  • Backup your data.
  • Detach any external drive (especially your external Time Machine backup drive)
  • Restart to Internet Recovery Mode by pressing alt cmd R at startup.
    The prerequisites are the latest firmware update installed, either ethernet or WLAN (WPA/WPA2) and a router with DHCP activated.
    On a 50 Mbps-line it takes about 4 min (presenting a small animated globe) to boot into a recovery netboot image which usually is loaded from an apple/akamai server.

    I recommend ethernet because it's more reliable. If you are restricted to WIFI and the boot process fails, just restart your Mac until you succeed booting.

    Alternatively you may start from a bootable installer thumb drive (Mavericks or Yosemite) or a thumb drive containing a full system (Mavericks or Yosemite).

    Below I assume that the disk identifier of your Internet Recovery HD (OS X Base System) or thumb drive is disk1, disk0 is your SSD, and disk2 your CoreStorage Logical Volume. Disk3 - ~ disk14 are used by Internet Recovery Mode. Don't mess around with them.
    LVUUID: UUID of the logical volume. PVUUID: UUID of the physical volume
    LVG: Logical Volume Group

'Repair':

  • First try to check the volume 'Macintosh HD' with Disk Utility. If the volume is corrupted consider a backup - if not already done previously - and a reinstall of Mac OS X.

  • If the volume is OK quit Disk Utility

  • Open Terminal and enter diskutil list, diskutil cs list, gpt -r -vvv show /dev/disk0 to get a clue of your disk layout and the sizes, UUIDs and names of the different partitions and volumes.
  • with the informations found in the different listings enter diskutil unmountDisk /dev/LogicalVolumeIdentifier and diskutil unmountDisk /dev/DiskContainingApple_CoreStorageIdentifier to first unmount the CoreStorage Volume and then the physical disk.

    In your case: first enter diskutil unmountDisk /dev/disk2, then diskutil unmountDisk /dev/disk0

  • remove the EFI NO NAME partition with gpt remove -i IndexNumberOfEFINoName DiskIdentifier:

    In your case: gpt remove -i 4 disk0

  • Remount the CoreStorage disk and then the Logical Volume:

    In your case: first diskutil mountDisk /dev/disk0 and then diskutil mountDisk /dev/disk2.

  • Now try diskutil cs resizeStack DC2473AF-0833-4DBD-BF8F-D5D60063554A 0g
    This command is undocumented but´usually works (check the size with diskutil list: Apple_CoreStorage should have ~500 GB instead of 450 GB now).

    If the command succeeds you are already done here and you may quit Terminal, open Disk Utility, check the volume for errors and then restart to your main OS.

    If the command fails you have to expand the whole stack manually.

  • Unmount the two disks again with diskutil unmountDisk /dev/disk2, then diskutil unmountDisk /dev/disk0
  • remove the Recovery HD partition with gpt remove -i IndexNumberOfRecoveryHD DiskIdentifier:

    In your case: gpt remove -i 3 disk0

  • Remount the CoreStorage disk and then the Logical Volume:

    In your case: first diskutil mountDisk /dev/disk0 and diskutil mountDisk /dev/disk2.

  • enter gpt -r -vvv show /dev/SSDApple_CoreStorageIdentfier to get verbose partition data of your SSD CoreStorage disk.

    In your case: gpt -r -vvv show /dev/disk0
    It should look similar (or equal) to the example below:

    gpt show: /dev/disk0: mediasize=500277790720; sectorsize=512; blocks=977105060
    gpt show: /dev/disk0: PMBR at sector 0
    gpt show: /dev/disk0: Pri GPT at sector 1
    gpt show: /dev/disk0: Sec GPT at sector 977105059
              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    878293176        2   GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
              878702816  98402211
              977105027        32            Sec GPT table
              977105059         1            Sec GPT header 
    
  • The free space consists of 98402211 blocks here.

    Calculate the biggest block number dividable through 8. That are 98402208 blocks (à 512 bytes) which equals 50381930496 B or ~50.4 GB.
    Add the size of your SSD CoreStorage Physical Volume (449686106112 B in your case).

    The result is 50381930496 B + 449686106112 B = 500068036608 B

  • Resize your SSD CoreStorage physical volume with diskutil cs resizeDisk PVUUID newsize

    In your case: diskutil cs resizeDisk 161E9D0A-9DC4-43C4-821F-8333FD14CEBB 500068036608b

  • Check the size of your Logical Volume Group. It should have an approx. size of 500068036608b (= ~500 GB)
  • Resize your Logical Volume with diskutil cs resizeVolume LVUUID LVGSize-128 MB.

    In your case that's diskutil cs resizeVolume DC2473AF-0833-4DBD-BF8F-D5D60063554A 499940036608b. If you get an error (There is not enough free space...) choose a smaller size like 499876036608b (=LVGSize-192 MB).

    Magical numbers like diskutil cs resizeVolume LVUUID 100% or diskutil cs resizeVolume LVUUID 0g sadly don't work here - at least for me.

  • Quit Terminal and open Disk Utility.
  • Check your expanded CoreStorage Volume for errors.
  • Quit Disk Utility, choose your now expanded CoreStorage volume as startup disk and restart your Mac
  • Reinstall your current system by downloading the appropriate installer from Apple to restore the Recovery HD deleted previously (e.g. if you are using 10.10.2 now download 10.10.2). Afterwards install all updates published later. You will NOT lose your personal data.

Solution 2:

I found another solution. It may take time though. You need to try reinstalling windows by using bootcamp and then uninstall it. When you ask bootcamp to delete the partition used for windows, it will also "delete" the free space. It worked for me.