MacOS – How to add free space to a Logical Volume Group? (Resizing Partitions)

core-storagedisk-utilitymacospartition

I have two CoreStorage volumes on disk, one is 200GB the other is 50GB. I want to make the 1st 125GB and the second one 125GB.

Currently I have been able to use the diskutil cs resizeStack command to shrink my 200GB disk to 125GB. But am unable to expand my second CoreStorage volume to 125GB since its Logical Volume Group doesn't contain the free space I generated.

CoreStorage logical volume groups (2 found)
|
+-- Logical Volume Group 5D6504C7-6C94-498E-B50C-64E3E4950AE0
|   =========================================================
|   Name:         Macintosh HD
|   Status:       Online
|   Size:         125318770688 B (125.3 GB)
|   Free Space:   0 B (0 B)
|   |
|   +-< Physical Volume 499AA4FC-31C1-47A3-8364-89A0C836125C
|   |   ----------------------------------------------------
|   |   Index:    0
|   |   Disk:     disk0s2
|   |   Status:   Online
|   |   Size:     125318770688 B (125.3 GB)
|   |
|   +-> Logical Volume Family 163A0B82-4315-4C68-8403-52B5A918C57C
|       ----------------------------------------------------------
|       Encryption Status:       Unlocked
|       Encryption Type:         AES-XTS
|       Conversion Status:       Complete
|       Conversion Direction:    -none-
|       Has Encrypted Extents:   Yes
|       Fully Secure:            Yes
|       Passphrase Required:     Yes
|       |
|       +-> Logical Volume 264CFBDC-8103-47E0-978E-738789320980
|           ---------------------------------------------------
|           Disk:                  disk1
|           Status:                Online
|           Size (Total):          124999999488 B (125.0 GB)
|           Conversion Progress:   -none-
|           Revertible:            Yes (unlock and decryption required)
|           LV Name:               Macintosh HD
|           Volume Name:           Macintosh HD
|           Content Hint:          Apple_HFS
|
+-- Logical Volume Group 4793C4C8-0F56-4673-A2B6-98B15403CD33
    =========================================================
    Name:         Macintosh HD 2
    Status:       Online
    Size:         55443439616 B (55.4 GB)
    Free Space:   28291072 B (28.3 MB)
    |
    +-< Physical Volume F67F2DAA-2E8E-4AE7-A976-42230747BAB4
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s4
    |   Status:   Online
    |   Size:     55443439616 B (55.4 GB)
    |
    +-> Logical Volume Family DB936707-28B4-4CE1-9B4A-292639232785
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         AES-XTS
        Conversion Status:       Complete
        Conversion Direction:    -none-
        Has Encrypted Extents:   Yes
        Fully Secure:            Yes
        Passphrase Required:     Yes
        |
        +-> Logical Volume 976CA58C-E8FF-492A-9968-6FEF64C58A31
            ---------------------------------------------------
            Disk:                  disk2
            Status:                Online
            Size (Total):          55079600128 B (55.1 GB)
            Conversion Progress:   -none-
            Revertible:            Yes (unlock and decryption required)
            LV Name:               Macintosh HD 2
            Volume Name:           Macintosh HD 2
            Content Hint:          Apple_HFS

Output from: df -k

Filesystem                        1024-blocks      Used Available Capacity  iused   ifree %iused  Mounted on
/dev/disk1                          122070312 101234644  20579668    84% 25372659 5144917   83%   /
devfs                                     189       189         0   100%      656       0  100%   /dev
map -hosts                                  0         0         0   100%        0       0  100%   /net
map auto_home                               0         0         0   100%        0       0  100%   /home
map -fstab                                  0         0         0   100%        0       0  100%   /Network/Servers
/dev/disk2                           53788672  43664860  10123812    82% 10916213 2530953   81%   /Volumes/Macintosh HD 2

Output from: diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage                         125.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:          Apple_CoreStorage                         55.4 GB    disk0s4
   5:                 Apple_Boot Recovery HD             650.0 MB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD 2         *55.1 GB    disk1
                                 Logical Volume on disk0s4
                                 976CA58C-E8FF-492A-9968-6FEF64C58A31
                                 Unlocked Encrypted
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           *125.0 GB   disk2
                                 Logical Volume on disk0s2
                                 264CFBDC-8103-47E0-978E-738789320980
                                 Unlocked Encrypted

Output from: sudo gpt -r -vvv show -l /dev/disk0

gpt show: /dev/disk0: mediasize=251000193024; sectorsize=512; blocks=490234752
gpt show: /dev/disk0: PMBR at sector 0
gpt show: /dev/disk0: Pri GPT at sector 1
gpt show: /dev/disk0: GPT partition: type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, start=40, size=409600
gpt show: /dev/disk0: GPT partition: type=53746F72-6167-11AA-AA11-00306543ECAC, start=409640, size=244763224
gpt show: /dev/disk0: GPT partition: type=426F6F74-0000-11AA-AA11-00306543ECAC, start=245172864, size=1269536
gpt show: /dev/disk0: GPT partition: type=53746F72-6167-11AA-AA11-00306543ECAC, start=380677208, size=108287968
gpt show: /dev/disk0: GPT partition: type=426F6F74-0000-11AA-AA11-00306543ECAC, start=488965176, size=1269536
gpt show: /dev/disk0: Sec GPT at sector 490234751
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - "EFI System Partition"
     409640  244763224      2  GPT part - "Macintosh HD"
  245172864    1269536      3  GPT part - "Recovery HD"
  246442400  134234808         
  380677208  108287968      4  GPT part - "Macintosh HD 2"
  488965176    1269536      5  GPT part - "Recovery HD"
  490234712          7         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

If I try to resize the logicalVolume, or the Stack or the Disk they all get the same error:

~ james$ diskutil coreStorage resizeDisk F67F2DAA-2E8E-4AE7-A976-42230747BAB4 125G
Started CoreStorage operation
Error: -69771: The target disk is too small for this operation

So as far as I can figure, I need to add the space to Logical Volume Group 4793C4C8-0F56-4673-A2B6-98B15403CD33.

Any help would be greatly appreciated!

Best Answer

You can't move the start block (=380677208 for LVG2 or "Macintosh HD 2" in your case) of a CoreStorage Volume (Group) non-destructively. The same is valid for non-CoreStorage partitions with on-board tools. AFAIK for the latter only iPartition and gparted work. Therefore you can't easily reclaim empty space with a lower start block and an arbitrary size and add it contiguously to existing CoreStorage or non-CoreStorage volumes.

Or with other words: You can expand volumes (CoreStorage or non-CoreStorage) from the ending block to higher block numbers but not from the starting block to lower ones.

You have 2 options though:

  • Recreating a larger second CoreStorage volume
  • Creating a new partition in the empty space and adding it as physical volume to your second Logical Volume Group. This will scatter your second Logical Volume Group over several Physical Volumes (PV2 & PV3 - the latter build in the empty space) on the same drive but might be unavoidable if another partition like your Recovery HD or a Data volume exists between LVG1 and immediately before PV2.

Both methods require you to backup/move the content of the second Logical Volume to another volume and its deletion afterwards.

For both methods force-backup all your data.

Then boot to an external thumb drive containing a bootable system or to Internet Recovery Mode (hit altcmdR immediately after the start-up chime)

  • open Terminal.app in the menubar (Utilities/Terminal)
  • enter diskutil cs list and diskutil list
  • enter diskutil cs deleteVolume LV2UUID to delete the second Logical Volume
    in your case diskutil cs deleteVolume 976CA58C-E8FF-492A-9968-6FEF64C58A31

Now the 2 different methods divert:

Recreating a larger second CoreStorage volume (recommended):

  • enter diskutil cs delete LVG2UUID to delete the second Logical Volume Group
    in your case diskutil cs delete 4793C4C8-0F56-4673-A2B6-98B15403CD33
    Your second Logical Volume Group will be converted to a classical volume with the name "Untitled". This will take some time because it also has to be decrypted.
  • If you enter diskutil cs list repeatedly you will see the progress of the decryption task (in %).
  • after the conversion completed enter sudo gpt -r -vvv show -l /dev/disk0*
    you have to enter an admin password then
    result (some parts omitted):

    ...
             40       409600      1  GPT part - "EFI System Partition"
         409640    244763224      2  GPT part - "Macintosh HD"
      245172864      1269536      3  GPT part - "Recovery HD"
      246442400(s) 134234808(a)         
      380677208    108287968(b)   4  GPT part - "Untitled"
      488965176      1269536      5  GPT part - "Recovery HD"
    ...  
    
  • enter diskutil list
  • enter diskutil unmountDisk /dev/DiskIdentifierLV (probably disk1) to unmount "Macintosh HD"
  • enter diskutil unmountDisk /dev/disk0
  • enter sudo gpt remove -i IndexNumber DiskIdentifier to remove a partition
    in your case sudo gpt remove -i 4 disk0 to remove the partition named "Untitled"
  • enter sudo gpt add -b StartBlock(s) -s NumberOfBlocks(a+b) DiskIdentifier to create a new partition filling the empty space.
    in your case probably sudo gpt add -b 246442400 -s 242522776 disk0
  • enter diskutil list to get the DiskIdentifier of your newly created partition (probably disk0s4)
  • enter diskutil cs create Name /dev/DiskIdentifier to recreate your second LVG
    in your case probably diskutil cs create "Macintosh HD 2" /dev/disk0s4
  • enter diskutil cs list to get the UUID of LVG2. Copy it.
  • enter diskutil cs createVolume LVG2UUID jhfs+ Name 100%
    in your case diskutil cs createVolume <-PasteTheLVG2UUIDHere-> jhfs+ "Macintosh HD 2" 100%
  • enter exit, quit Terminal and reboot to "Macintosh HD"
  • Open "Disk Utility", check the newly created CoreStorage volume "Macintosh HD 2" and quit the app
  • open the Info window of the volume in Finder and uncheck the box labeled 'Ignore ownership on this volume'.
  • enable FileVault for the volume/encrypt it
  • restore "Macintosh HD 2" from your Time Machine backup

Scattered brain PhysicalVolumes method (not recommended but sometimes necessary):

This method is necessary if sudo gpt -r -vvv show -l /dev/disk0 shows following result (some parts omitted):

    ...
             40       409600      1  GPT part - "EFI System Partition"
         409640    244763224      2  GPT part - "Macintosh HD"
      245172864      1269536      3  GPT part - "Recovery HD"
      246442400     83034808
      329477208     51200000      4  GPT part - "Data"         
      380677208    108287968      5  GPT part - "Macintosh HD 2"
      488965176      1269536      6  GPT part - "Recovery HD"
    ... 

This partition layout may occur if you have an additional Data partition between your 2 CoreStorage volumes.

  • enter diskutil list
  • enter diskutil unmountDisk /dev/DiskIdentifierLV (probably disk1) to unmount "Macintosh HD"
  • enter diskutil unmountDisk /dev/disk0
  • enter sudo gpt add -b StartBlock -s NumberOfBlocks DiskIdentifier to create new partition filling the empty space.
    in the case above sudo gpt add -b 246442400 -s 83034808 disk0
  • enter diskutil list to get the DiskIdentifier of the newly created partition (probably disk0s6 - check the size!)
  • enter diskutil cs list to get the LVG2UUID
  • enter diskutil cs addDisk LVG2UUID DiskIdentifier to add a physical disk to LVG2
    in your case diskutil cs addDisk 4793C4C8-0F56-4673-A2B6-98B15403CD33 disk0s6
  • enter diskutil cs createVolume LVG2UUID jhfs+ Name 100% to create a new Logical Volume in LVG2
    in your case diskutil cs createVolume 4793C4C8-0F56-4673-A2B6-98B15403CD33 jhfs+ "Macintosh HD 2" 100%
  • enter exit, quit Terminal and reboot to "Macintosh HD"
  • Open "Disk Utility", check the newly created CoreStorage volume "Macintosh HD 2" and quit the app
  • open the Info window of the volume in Finder and uncheck the box labeled 'Ignore ownership on this volume'.
  • enable FileVault for the volume/encrypt it
  • restore "Macintosh HD 2" from your Time Machine backup

*You don't have to enter 'sudo gpt...' if you are logged in as root (e.g. Internet Recovery Mode)