Mac – Can’t expand primary partition used by Time Machine

disk-utilitypartitiontime-machine

I have a 1TB external hard drive which had two partitions. 400G for Time Machine and 600G for random stuff. I'm using macOS Sierra 10.12.2.

➜  ~ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Macintosh HD           +499.1 GB   disk1
                                 Logical Volume on disk0s2
                                 2C4E67F3-5642-4E87-82E2-38D7079B736E
                                 Unlocked Encrypted

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:          Apple_CoreStorage Backup                  400.0 GB   disk2s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk2s3
   4:                  Apple_HFS Jumbo                   599.7 GB   disk2s4

/dev/disk3 (external, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Backup                 +399.7 GB   disk3
                                 Logical Volume on disk2s2
                                 E8E8E5D6-E9F2-45F4-A55A-AD126D187790
                                 Unlocked Encrypted

➜  ~ gpt -r -vv show /dev/disk2
gpt show: /dev/disk2: mediasize=1000204886016; sectorsize=512; blocks=1953525168
gpt show: /dev/disk2: PMBR at sector 0
gpt show: /dev/disk2: Pri GPT at sector 1
gpt show: /dev/disk2: Sec GPT at sector 1953525167
       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   781250000      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
   781659640      262144      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
   781921784  1171341200      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1953262984      262151
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header  

Now I want to switch the sizes by reducing the 600G partition and extending the 400G partition. Reducing went like a charm with diskutil resizeVolume disk2s4 300G.

➜  ~ gpt -r -vv show /dev/disk2
gpt show: /dev/disk2: mediasize=1000204886016; sectorsize=512; blocks=1953525168
gpt show: /dev/disk2: PMBR at sector 0
gpt show: /dev/disk2: Pri GPT at sector 1
gpt show: /dev/disk2: Sec GPT at sector 1953525167
       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   781250000      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
   781659640      262144      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
   781921784   585937496      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  1367859280   585665855
  1953525135          32         Sec GPT table
  1953525167           1         Sec GPT header

Now the expand part:

I found this answer and followed the steps mentioned there.

➜  ~ diskutil cs list
CoreStorage logical volume groups (2 found)
|
+-- Logical Volume Group 28A27FF8-1376-4F14-9AEF-ED6B306564E6
|   =========================================================
|   Name:         Macintosh HD
|   Status:       Online
|   Size:         499418034176 B (499.4 GB)
|   Free Space:   4096 B (4.1 KB)
|   |
|   +-< Physical Volume 768A2ECD-804E-4657-B4B5-1D2222671DEA
|   |   ----------------------------------------------------
|   |   Index:    0
|   |   Disk:     disk0s2
|   |   Status:   Online
|   |   Size:     499418034176 B (499.4 GB)
|   |
|   +-> Logical Volume Family AD757291-D990-44F6-81C7-C1CD171CA6E7
|       ----------------------------------------------------------
|       Encryption Type:         AES-XTS
|       Encryption Status:       Unlocked
|       Conversion Status:       Complete
|       High Level Queries:      Fully Secure
|       |                        Passphrase Required
|       |                        Accepts New Users
|       |                        Has Visible Users
|       |                        Has Volume Key
|       |
|       +-> Logical Volume 2C4E67F3-5642-4E87-82E2-38D7079B736E
|           ---------------------------------------------------
|           Disk:                  disk1
|           Status:                Online
|           Size (Total):          499082485760 B (499.1 GB)
|           Revertible:            Yes (unlock and decryption required)
|           Revert Status:         Reboot required
|           LV Name:               Macintosh HD
|           Volume Name:           Macintosh HD
|           Content Hint:          Apple_HFS
|
+-- Logical Volume Group 734FF1FC-20B6-4875-B557-D31A5D7C78EB
    =========================================================
    Name:         Backup
    Status:       Online
    Size:         400000000000 B (400.0 GB)
    Free Space:   4096 B (4.1 KB)
    |
    +-< Physical Volume 4196C157-11E1-465C-A822-A9FAFAC7E9C7
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk2s2
    |   Status:   Online
    |   Size:     400000000000 B (400.0 GB)
    |
    +-> Logical Volume Family 255E74B3-8F71-4715-9CA7-A1640CDA9EB3
        ----------------------------------------------------------
        Encryption Type:         AES-XTS
        Encryption Status:       Unlocked
        Conversion Status:       Complete
        High Level Queries:      Fully Secure
        |                        Passphrase Required
        |                        Accepts New Users
        |                        Has Visible Users
        |                        Has Volume Key
        |
        +-> Logical Volume E8E8E5D6-E9F2-45F4-A55A-AD126D187790
            ---------------------------------------------------
            Disk:                  disk3
            Status:                Online
            Size (Total):          399664451584 B (399.7 GB)
            Revertible:            Yes (unlock and decryption required)
            LV Name:               Backup
            Volume Name:           Backup
            Content Hint:          Apple_HFS

Since Backup was a CoreStorage volume I used diskutil cs resizeStack E8E8E5D6-E9F2-45F4-A55A-AD126D187790 0g without success. Sadly, I don't have the exact error message anymore but it was something similar to "The new size must be different than the existing size". (You'll see later where this message comes from.) I also tried diskutil cs resizeVolume and resizeDisk cs resizeDisk without success.

This is how it looks in Disk Utility:

Disk Utility
There is no toggle to resize Backup, only Jumbo has one.

Now I thought that this might be caused by the fact that Backup is an encrypted volume. So I disabled encryption in Time Machine. 12 hours later and Backup is now Apple_HFS:

➜  ~ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Macintosh HD           +499.1 GB   disk1
                                 Logical Volume on disk0s2
                                 2C4E67F3-5642-4E87-82E2-38D7079B736E
                                 Unlocked Encrypted

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS Backup                  400.0 GB   disk2s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk2s3
   4:                  Apple_HFS Jumbo                   300.0 GB   disk2s4

disk2s2 is the volume I want to resize:

➜  ~ diskutil resizeVolume disk2s2 R
Resizing to full size (fit to fill)
Started partitioning on disk2s2 Backup
Error: -69743: The new size must be different than the existing size

Boom, still doesn't work. Let's try 700G (300G (current) + 400G (free)):

➜  ~ diskutil resizeVolume disk2s2 700G
Resizing to 700000000000 bytes
Started partitioning on disk2s2 Backup
Error: -69771: The target disk is too small for this operation

OK, let's take a look at the limits:

➜  ~ diskutil resizeVolume disk2s2 limits
Resize limits for partition disk2s2 Backup:
  Current partition size on map:              400.0 GB (400000000000 Bytes)
  Minimum size (constrained by file usage):   306.2 GB (306166493184 Bytes)
  Recommended minimum size (if used for OS):  311.5 GB (311535202304 Bytes)
  Maximum size (constrained by map space):    400.0 GB (400000000000 Bytes)

Note: I tried all the steps in normal mode and the recovery mode with the same results.

So, somehow there is a "maximum size constrained by map space" and I don't know what it means. How can I change the size? Is that what is blocking me from expanding the volume?

Here's there output of diskutil info to provide some more details :

➜  ~ diskutil info disk2
   Device Identifier:        disk2
   Device Node:              /dev/disk2
   Whole:                    Yes
   Part of Whole:            disk2
   Device / Media Name:      024 HN-M101MBB

   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None

   Content (IOContent):      GUID_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported

   Disk Size:                1.0 TB (1000204886016 Bytes) (exactly 1953525168 512-Byte-Units)
   Device Block Size:        512 Bytes

   Read-Only Media:          No
   Read-Only Volume:         Not applicable (no file system)

   Device Location:          External
   Removable Media:          Fixed

   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

➜  ~ diskutil info disk2s2
   Device Identifier:        disk2s2
   Device Node:              /dev/disk2s2
   Whole:                    No
   Part of Whole:            disk2

   Volume Name:              Backup
   Mounted:                  Yes
   Mount Point:              /Volumes/Backup

   Partition Type:           Apple_HFS
   File System Personality:  Journaled HFS+
   Type (Bundle):            hfs
   Name (User Visible):      Mac OS Extended (Journaled)
   Journal:                  Journal size 32768 KB at offset 0xba7000
   Owners:                   Enabled

   OS Can Be Installed:      Yes
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Volume UUID:              0FC68EF3-FF25-3C90-93DA-87236A2DBFAF
   Disk / Partition UUID:    1E1BED05-CD09-4945-B60C-A7B45F28F76C

   Disk Size:                400.0 GB (400000000000 Bytes) (exactly 781250000 512-Byte-Units)
   Device Block Size:        512 Bytes

   Volume Total Space:       400.0 GB (400000000000 Bytes) (exactly 781250000 512-Byte-Units)
   Volume Used Space:        306.1 GB (306149363712 Bytes) (exactly 597947976 512-Byte-Units) (76.5%)
   Volume Available Space:   93.9 GB (93850636288 Bytes) (exactly 183302024 512-Byte-Units) (23.5%)
   Allocation Block Size:    4096 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No

   Device Location:          External
   Removable Media:          Fixed

Edit 1: According to diskutil cs list the external disk has no CoreStorage anymore:

➜  ~ diskutil cs list
CoreStorage logical volume groups (1 found)
|
+-- Logical Volume Group 28A27FF8-1376-4F14-9AEF-ED6B306564E6
    =========================================================
    Name:         Macintosh HD
    Status:       Online
    Size:         499418034176 B (499.4 GB)
    Free Space:   4096 B (4.1 KB)
    |
    +-< Physical Volume 768A2ECD-804E-4657-B4B5-1D2222671DEA
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     499418034176 B (499.4 GB)
    |
    +-> Logical Volume Family AD757291-D990-44F6-81C7-C1CD171CA6E7
        ----------------------------------------------------------
        Encryption Type:         AES-XTS
        Encryption Status:       Unlocked
        Conversion Status:       Complete
        High Level Queries:      Fully Secure
        |                        Passphrase Required
        |                        Accepts New Users
        |                        Has Visible Users
        |                        Has Volume Key
        |
        +-> Logical Volume 2C4E67F3-5642-4E87-82E2-38D7079B736E
            ---------------------------------------------------
            Disk:                  disk1
            Status:                Online
            Size (Total):          499082485760 B (499.1 GB)
            Revertible:            Yes (unlock and decryption required)
            Revert Status:         Reboot required
            LV Name:               Macintosh HD
            Volume Name:           Macintosh HD
            Content Hint:          Apple_HFS

Best Answer

The resizeStack command doesn't allow to resize a CoreStorage stack with two subsequent partitions - disk2s3 and disk2s4.

Based on the state of the disk before removing the CoreStorage stack ("disabled encryption in Time Machine" - which isn't necessary) do the following:

Resize Jumbo slightly to fit into the unallocated disk space:

diskutil resizeVolume disk2s4 299860918272b

Then - after unmounting all disks related to disk2 - create a fifth partition right after disk2s4 with the same size as disk2s4

diskutil umountDisk disk3
diskutil umountDisk disk2
sudo gpt add -i 5 -b 1367587640 -s 585665856 -t 48465300-0000-11AA-AA11-00306543ECAC disk2

Format disk2s5 as HFSJ volume, rename it to Jumbo2 and restore Jumbo to Jumbo2.

Remove disk2s4:

diskutil umountDisk disk3
diskutil umountDisk disk2
sudo gpt remove -i 4 disk2

Resize the CoreStorage stack:

diskutil cs resizeStack E8E8E5D6-E9F2-45F4-A55A-AD126D187790 0g

Since you already removed encryption (and the CoreStorage stack) the method is slightly different:

diskutil resizeVolume disk2s4 299860918272b

Then - after unmounting disk2 - create a fifth partition right after disk2s4 with the same size as disk2s4

diskutil umountDisk disk2
sudo gpt add -i 5 -b 1367587640 -s 585665856 -t 48465300-0000-11AA-AA11-00306543ECAC disk2

Format disk2s5 as HFSJ volume, rename it to Jumbo2 and restore Jumbo to Jumbo2.

Remove disk2s4:

diskutil umountDisk disk2
sudo gpt remove -i 4 disk2

Resize disk2s2:

diskutil resizeVolume disk2s2 700g

If you get an error (disk too small) choose a slightly smaller size like 699720m


My test disk was slightly bigger than yours but I tried to use the sizes of your partitions - you may have to recheck the sizes in the various commands in case I made an error somewhere. And: it was an ad-hoc solution which isn't optimized regarding unallocated disk space.

An optimized approach:

The 4k aligned disk space following disk2s3 is 1953525128 blocks - 781921784 blocks = 1171603344 blocks. By dividing this by 2 you will get two equally sized partitions which allows the restore of Jumbo to Jumbo2 = 585801672 blocks. So resizing Jumbo to 585801672 blocks = 299930456064 Bytes allows you to create a 5th partition with the same size as disk2s4.

diskutil resizeVolume disk2s4 299930456064b
diskutil umountDisk disk2
sudo gpt add -i 5 -b 1367723456 -s 585801672 -t 48465300-0000-11AA-AA11-00306543ECAC disk2

Format disk2s5 as HFSJ volume, rename it to Jumbo2 and restore Jumbo to Jumbo2.

Remove disk2s4:

diskutil umountDisk disk2
sudo gpt remove -i 4 disk2

Resize disk2s2:

diskutil resizeVolume disk2s2 699860918272b