Resize FusionDrive to fill empty space

core-storagedisk-utilityfusion-drivepartition

Context: I wanted to install Windows 8 onto my Mac by repartitioning my FusionDrive. Using the partition BootCamp provided didn't work, so I found a "solution" on Apple forums to create empty space instead and have the Windows installation media create a partition. Windows created the partition, but wouldn't install.

I went back to DiskUtility to erase the partitions it created (1 big one and 2 small ones). After trying to get rid of them I'm now stuck with a large amount of empty space in my FusionDrive and DiskUtility won't let me fill it or resize anything regarding the empty space (I've tried this in recovery mode too).

Here is what my DiskUtility looks like (ignore the 16GB USB): DiskUtility

The two drives my FusionDrive is compromised of are disk0 (1TB HDD) and disk1 (100GB SSD) from here:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage                         119.7 GB   disk0s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:          Apple_CoreStorage                         626.1 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.1 MB   disk1s3
   4:                        EFI NO NAME                 104.9 MB   disk1s4
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           *739.9 GB   disk2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB    disk3
   1:                 DOS_FAT_32 WININSTALL              15.9 GB    disk3s1

You can see that my FusionDrive is disk2, and shows up with around 740GB.

Here is my CoreStorage list (I believe this is helpful):

CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group 57932797-4AC8-4475-9836-82394CEBF536
    =========================================================
    Name:         LogicalVolumeGroup
    Status:       Online
    Size:         745750200320 B (745.8 GB)
    Free Space:   353689600 B (353.7 MB)
    |
    +-< Physical Volume 68F90B2B-4004-4044-AFFB-9D3854006D2A
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     119690149888 B (119.7 GB)
    |
    +-< Physical Volume 9CB6C261-6817-42F0-B2EB-09F057462EBD
    |   ----------------------------------------------------
    |   Index:    1
    |   Disk:     disk1s2
    |   Status:   Online
    |   Size:     626060050432 B (626.1 GB)
    |
    +-> Logical Volume Family 9B947A52-7496-46CA-BFA5-A87DD47249FE
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-> Logical Volume 86417B41-6400-4F81-8F7C-43AA243CDAEE
            ---------------------------------------------------
            Disk:                  disk2
            Status:                Online
            Size (Total):          739901915136 B (739.9 GB)
            Conversion Progress:   -none-
            Revertible:            No
            LV Name:               Macintosh HD
            Volume Name:           Macintosh HD
            Content Hint:          Apple_HFS

How can I regain my FusionDrive's empty space?

Best Answer

Basically the same applies as in this question and the accepted answer. The only difference is that you have a fusion drive and therefore some DiskIdentifiers differ.

Additionally you have a blocking partition on your HDD with certainty which has to be removed.

There is one undocumented command to resize or expand a CoreStorage volume group and an inherent logical volume:

diskutil cs resizeStack LVUUID size  

The command expands or shrinks the whole CoreStorage Volume Group including the physical volume(s), the logical volume family and the logical volume in one step to the desired size.

Beware: The command is vastly undocumented and as such potentially destructive.

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 to 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). The disk identifiers may differ then. So check the human readable names and sizes and change the commands below accordingly.

Get an overview:

  • Open in the menubar Utilities/Terminal

    First you should get an overview of your disks and the partition layout:

  • Enter diskutil list
    Example listing (but I took the list provided by you in your question and included the netboot device):

    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *120.0 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:          Apple_CoreStorage                         119.7 GB   disk0s2
       3:                 Apple_Boot Boot OS X               134.2 MB   disk0s3
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.0 TB     disk1
       1:                        EFI EFI                     209.7 MB   disk1s1
       2:          Apple_CoreStorage                         626.1 GB   disk1s2
       3:                 Apple_Boot Recovery HD             650.1 MB   disk1s3
       4:                        EFI NO NAME                 104.9 MB   disk1s4
    /dev/disk2
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:     Apple_partition_scheme                         *1.3 GB    disk2
       1:        Apple_partition_map                         30.7 KB    disk2s1
       2:                  Apple_HFS OS X Base System        *1.3 GB    disk2s2
    /dev/disk3
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:                  Apple_HFS Macintosh HD           *739.9 GB   disk3
    
    /dev/disk4-disk14 ...belong to the OS X Base System (your recovery system you booted to previously)
    

    Disk0 is your first main internal disk device (SSD) containing an EFI-partition (dis0s1), one CoreStorage partition (disk0s2) and Boot OS X (disk0s3).

    Disk1 is your second main internal disk device (HDD) containing an EFI-partition (dis1s1), one CoreStorage partition (disk1s2) and the Recovery HD (disk1s3). Additionally the disk contains a second EFI partition (disk1s4), which is a remains of your failed Boot Camp install.

    Disk2 is a logical disk created by booting to the netboot image which contains a recovery system (OS X Base System = disk2s2) similar to the Recovery HD.

    Disk3 is also a logical disk residing in disk0s2 and disk1s2 and it contains the CoreStorage stack.

  • Enter gpt -r -vv show /dev/disk1 to get the index number of the blocking partition
    Example listing (your sizes differ):

    gpt show: /dev/disk1: mediasize=68719476736; sectorsize=512; blocks=134217728
    gpt show: /dev/disk1: PMBR at sector 0
    gpt show: /dev/disk1: Pri GPT at sector 1
    gpt show: /dev/disk1: Sec GPT at sector 134217727
          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  104974016      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
      105383656    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
      106653192     204800      4  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      106857992   27359703         
      134217695         32         Sec GPT table
      134217727          1         Sec GPT header
    

    The partition with the index number 1 is a regular EFI-partition, the partition with index number 2 is your second CoreStorage physical volume and the partition with index number 3 is your Recovery HD.
    The partition with index number 4 (= No Name EFI) usually only exists if you had a failed Boot Camp install or removed a subsequent Windows partition manually. All the rest is unallocated free space (in the example 27359703 blocks à 512 B).

  • Enter diskutil cs list
    Example listing (but I took the list provided by you in your question):

    CoreStorage logical volume groups (1 found)
    |
    +-- Logical Volume Group 57932797-4AC8-4475-9836-82394CEBF536
        =========================================================
        Name:         LogicalVolumeGroup
        Status:       Online
        Size:         745750200320 B (745.8 GB)
        Free Space:   353689600 B (353.7 MB)
        |
        +-< Physical Volume 68F90B2B-4004-4044-AFFB-9D3854006D2A
        |   ----------------------------------------------------
        |   Index:    0
        |   Disk:     disk0s2
        |   Status:   Online
        |   Size:     119690149888 B (119.7 GB)
        |
        +-< Physical Volume 9CB6C261-6817-42F0-B2EB-09F057462EBD
        |   ----------------------------------------------------
        |   Index:    1
        |   Disk:     disk1s2
        |   Status:   Online
        |   Size:     626060050432 B (626.1 GB)
        |
        +-> Logical Volume Family 9B947A52-7496-46CA-BFA5-A87DD47249FE
            ----------------------------------------------------------
            Encryption Status:       Unlocked
            Encryption Type:         None
            Conversion Status:       NoConversion
            Conversion Direction:    -none-
            Has Encrypted Extents:   No
            Fully Secure:            No
            Passphrase Required:     No
            |
            +-> Logical Volume 86417B41-6400-4F81-8F7C-43AA243CDAEE
                ---------------------------------------------------
                Disk:                  disk3
                Status:                Online
                Size (Total):          739901915136 B (739.9 GB)
                Conversion Progress:   -none-
                Revertible:            No
                LV Name:               Macintosh HD
                Volume Name:           Macintosh HD
                Content Hint:          Apple_HFS
    

Remove blocking partition:

  • to resize the CoreStorage volume you have to delete any blocking partition first (the Recovery HD doesn't count because it usually will be moved with the resizeStack command).
    First you have to unmount all mounted volumes on disk0 and disk1 (first the CoreStorage volume, which has its own disk identifier disk3 but resides on disk0 and disk1, then all other mounted volumes on disk0 and disk1 - check this with df):

    diskutil unmount /dev/disk3
    

    then additional volumes (if you have any at all). Example:

    diskutil unmount /dev/disk1s5
    

    Now delete the NoName EFI partition by entering:

    gpt remove -i 4 disk1
    
  • Remount any previously unmounted volume in the reverse order with

    diskutil mount /dev/disk1s5
    diskutil mount /dev/disk3 
    

Modify CoreStorage stack:

  • Since any blocking partition (in your case the NO NAME EFI partition) is deleted you may now resize the CoreStorage volume with

    diskutil cs resizeStack LVUUID size 
    

    with LVUUID: UUID of the logical volume and size: the final size of your CoreStorage volume.

    Examples:

    diskutil cs resizeStack 86417B41-6400-4F81-8F7C-43AA243CDAEE 900g  
    

    to expand it to 900 GB

    diskutil cs resizeStack 86417B41-6400-4F81-8F7C-43AA243CDAEE 500g  
    

    to shrink it to 500 GB

    diskutil cs resizeStack 86417B41-6400-4F81-8F7C-43AA243CDAEE 0g 
    

    to expand it to the full available size (0g is a magic number here).

    Your Recovery HD should be moved automatically - regardless of whether shrinking or expanding the CS volume - to the very end of it (right after the CoreStorage volume).

  • In case of shrinking or not expanding the CoreStorage volume to the full available size you may now create a 2nd partition with gpt.
  • Enter the following to get the new partition scheme:

    gpt -r -vv show /dev/disk1
    

    and

    gpt add -b StartBlock -i IndexNumber -s SizeOfPartition -t PartitionType disk1
    

    to create a new partition. StartBlock is the number of the first block in the unallocated space and NumberOfBlocks is the number of free blocks or smaller. NumberOfBlocks has to be dividable through 8!

  • Enter exit and quit Terminal.
  • Open Disk Utility (and format your newly created partition if you have created a new partition in the second last step).
  • Then check your expanded CoreStorage volume for errors.
  • Quit Disk Utility.
  • Reboot to your main volume.