MacOS – Resizing or expanding a CoreStorage volume

core-storagedisk-utilitymacospartition

I bought a new SSD with 750 GB and made two partitions: 600 GB and 150 GB. The smaller one was thought to be a Bootcamp partition one day, but to date it was just another unused partition. When I needed more space, I decided to merge these two partitions. The partition was created with Mavericks, the merge was done with Yosemite.

I opened Disk Utility and the "minus" button. Disk Utility told me both partitions would be merged then. However it miserably failed. My main hard disc suddenly had errors which couldn't be repaired and even two of my other external hard discs could not be mounted any longer.

I eventually restored the hard disc from Time Machine, which worked well.

My second partition is now listed as free:

Disk Utility

Unfortunately I can't resize the 600 GB partition nor can I create a new partition using the free space.

Diskutil reveils the following:

~  diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage                         599.6 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           *599.3 GB   disk1
                                 Logical Volume on disk0s2
                                 XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
                                 Unencrypted

Also diskutil brought up this:

~  diskutil cs list
CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group 9D2BA4BA-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    =========================================================
    Name:         Macintosh HD
    Status:       Online
    Size:         599640592384 B (599.6 GB)
    Free Space:   6111232 B (6.1 MB)
    |
    +-< Physical Volume 29A9A02B-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     599640592384 B (599.6 GB)
    |
    +-> Logical Volume Family 2FA7892F-xxxx-xxxx-xxxx-xxxxxxxxxxxx
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-> Logical Volume 7BF42B7B-xxxx-xxxx-xxxx-xxxxxxxxxxxx
            ---------------------------------------------------
            Disk:                  disk1
            Status:                Online
            Size (Total):          599282155520 B (599.3 GB)
            Conversion Progress:   -none-
            Revertible:            No
            LV Name:               Macintosh HD
            Volume Name:           Macintosh HD
            Content Hint:          Apple_HFS

I have tried this:

but it wouldn't help. It said I couldn't recover because it wasn't created in a way it would support (sorry for missing the exact message).

I then have learned that Apple_CoreStorage might indicate my disk is encrypted, which might explain why I can't resize it. It doesn't explain why I can't create a new partition to me.

What are my options to make my hard disk available in a single partition with size 750 GB?

Best Answer

After gaining some experience with CoreStorage volumes, I reworked my first answer to generalize and facilitate it by adding some scenarios and deleting some dispensable steps.

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

While shrinking it down to the size of the occupied space in the logical volume shouldn't be problem at all (but not recommended because at least 10% free space should be left), any blocking partition except the recovery partition has to be deleted or diminished before expanding the CoreStorage stack.

The command comes in handy in several scenarios:

  • expanding a CoreStorage volume after deleting a 2nd old-style JHFS+ volume on the same device (this may happen after splitting your disk in two partitions in Mavericks and then updating to Yosemite. The first partition - your system volume - might be converted to a CoreStorage volume, while the 2nd volume is left alone.)

enter image description here

  • expanding a CoreStorage volume after manually deleting a Boot Camp NTFS volume

enter image description here

  • resizing a CoreStorage volume to create 2nd old-style JHFS+ volume on the same device

enter image description here

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

Modify CoreStorage stack:

  • Open in the menubar Utilities/Terminal

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

  • Enter diskutil list
    Example listing:

    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *68.7 GB    disk0
       1:                        EFI EFI                    209.7 MB    disk0s1
       2:          Apple_CoreStorage                         53.7 GB    disk0s2
       3:                 Apple_Boot Recovery HD            650.0 MB    disk0s3
       4:                        EFI No Name EFI            100.0 MB    disk0s4
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:     Apple_partition_scheme                         *1.3 GB    disk1
       1:        Apple_partition_map                         30.7 KB    disk1s1
       2:                  Apple_HFS OS X Base System        *1.3 GB    disk1s2
    /dev/disk2
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:                  Apple_HFS System                 *53.5 GB    disk2
    /dev/disk3-disk12 ...belong to the OS X Base System (your recovery system you booted to previously)
    

    Disk0 is your main internal disk device containing the EFI-partition (dis0s1), the CoreStorage partition (disk0s2) and the Recovery HD (disk0s3). The No Name EFI (disk0s4) only exists if you had a Boot Camp partition previously and deleted it manually.

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

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

  • Enter gpt -r -vv show /dev/disk0
    Example listing:

    gpt show: /dev/disk0: mediasize=68719476736; sectorsize=512; blocks=134217728
    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 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 the regular EFI-partition, the partition with index number 2 is your CoreStorage partition and the partition with index number 3 is your Recovery HD.
    The partition with index number 4 (=No Name EFI) only exists if you had a Boot Camp partition previously and deleted it manually. All the rest is unallocated free space (in the example 27359703 blocks à 512 B).

  • Enter diskutil cs list
    Example listing:

      CoreStorage logical volume groups (1 found)
    |
    +-- Logical Volume Group A629E051-D7B0-4B8C-A803-074F62704636
        =========================================================
        Name:         System
        Status:       Online
        Size:         53946696192 B (53.9 GB)
        Free Space:   16777216 B (16.8 MB)
        |
        +-< Physical Volume 90C09FC0-4215-4871-901B-70E2C9C7D464
        |   ----------------------------------------------------
        |   Index:    0
        |   Disk:     disk0s2
        |   Status:   Online
        |   Size:     53946696192 B (53.9 GB)
        |
        +-> Logical Volume Family F6962E38-50E4-4458-BFE6-CF2E179352F5
            ----------------------------------------------------------
            Encryption Status:       Unlocked
            Encryption Type:         None
            Conversion Status:       NoConversion
            Conversion Direction:    -none-
            Has Encrypted Extents:   No
            Fully Secure:            No
            Passphrase Required:     No
            |
            +-> Logical Volume BD36C73D-860D-4DC6-B125-AD624F448B88
                ---------------------------------------------------
                Disk:                  disk2
                Status:                Online
                Size (Total):          53496696192 B (53.5 GB)
                Conversion Progress:   -none-
                Revertible:            Yes (no decryption required)
                LV Name:               System
                Volume Name:           System
                Content Hint:          Apple_HFS
    
  • 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 (first the CoreStorage volume, which has its own disk identifier disk2 but resides on disk0, then all other mounted volumes on disk0 - check this with df):

    diskutil unmountDisk /dev/disk2
    

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

    diskutil unmount /dev/disk0s5 
    

    If you have a NoName EFI partition delete it by entering:

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

    diskutil mount /dev/disk0s5
    diskutil mount /dev/disk2 
    
  • Since any blocking 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 BD36C73D-860D-4DC6-B125-AD624F448B88 60g  
    

    to expand it to 60 GB

    diskutil cs resizeStack BD36C73D-860D-4DC6-B125-AD624F448B88 40g  
    

    to shrink it to 40 GB

    diskutil cs resizeStack BD36C73D-860D-4DC6-B125-AD624F448B88 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.

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

    gpt -r -vv show /dev/disk0
    

    and

    gpt add -b StartBlock -s NumberOfBlocks disk0
    

    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.