2

I cloned a Time Machine backup from a 1TB SSD to a 2TB SSD, using a SSD Docking Station (This product to be exact. It probably behaves similarly to Clonezilla). This resulted in the 2TB SSD having one APFS partition with 1TB and unused space of 1TB. I want to re-partition the APFS partition so that it uses the entire 2TB available on the new SSD.

I tried editing the GUID partition table (GPT) using gpt remove as described in this thread, but the command fails to because of an operation not permitted error. I was hoping to run diskutil apfs resizeContainer after this to claim the unused space.

Would someone offer any insights on this matter? I'd be grateful!


Command for removing GPT index (Ran on both normal and recovery boot)

➜  ~ sudo gpt -f remove -i 2 /dev/disk4
gpt remove: operation not permitted: remove

Command for resizing APFS Container

➜  ~ diskutil apfs resizeContainer disk4s2 0
Started APFS operation
Error: -69743: The new size must be different than the existing size

Disk Information (Notice the (free space) 1.0 TB)

➜  ~ diskutil list external

/dev/disk4 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *2.0 TB disk4 1: EFI EFI 209.7 MB disk4s1 2: Apple_APFS Container disk5 1000.0 GB disk4s2 (free space) 1.0 TB -

/dev/disk5 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +1000.0 GB disk5 Physical Store disk4s2 1: APFS Volume TimeMachine 937.7 GB disk5s2

➜ ~ diskutil apfs list ...

+-- Container disk5 AFEF2475-D211-4D77-978C-928F6D3A260D

APFS Container Reference:     disk5
Size (Capacity Ceiling):      999995129856 B (1000.0 GB)
Capacity In Use By Volumes:   937923084288 B (937.9 GB) (93.8% used)
Capacity Not Allocated:       62072045568 B (62.1 GB) (6.2% free)
|
+-< Physical Store disk4s2 11DDF4B6-A80A-4E33-A986-98FFD4FF9905
|   -----------------------------------------------------------
|   APFS Physical Store Disk:   disk4s2
|   Size:                       999995129856 B (1000.0 GB)
|
+-> Volume disk5s2 20030003-E683-424F-9C17-173CBF4A58EC
    ---------------------------------------------------
    APFS Volume Disk (Role):   disk5s2 (Backup)
    Name:                      TimeMachine (Case-sensitive)
    Mount Point:               /Volumes/TimeMachine
    Capacity Consumed:         937715933184 B (937.7 GB)
    Sealed:                    No
    FileVault:                 No

GUID Partition Table on new SSD (free space starts from Sector 1953525128)

➜  ~ sudo gpt show /dev/disk4
Password:
       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  1953115488      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  1953525128  1953504007
  3907029135          32         Sec GPT table
  3907029167           1         Sec GPT header

I use Macbook Pro (Apple Silicon) with macOS Somona, as listed below:

➜  ~ sw_vers
ProductName:        macOS
ProductVersion:     14.6.1
BuildVersion:       23G93
ric.row
  • 179

1 Answers1

0

The method described here worked.

First Aid in Disk Utility GUI does not detect any anomaly. However, you can fix issues from the terminal with sudo diskutil repairdisk disk4.

You can then run diskutil apfs resizeContainer disk4s2 0 to resize the partition into the full space of the drive.


Command to repair new SSD

➜  ~ sudo diskutil repairdisk disk4
Password:
Repairing the partition map might erase disk4s1, proceed? (y/N) y
Started partition map repair on disk4
Checking prerequisites
Checking the partition list
Adjusting partition map to fit whole disk as required
Checking for an EFI system partition
Checking the EFI system partition's size
Checking the EFI system partition's file system
Checking the EFI system partition's folder content
Checking all HFS data partition loader spaces
Checking booter partitions
Reviewing boot support loaders
Checking Core Storage Physical Volume partitions
The partition map appears to be OK
Finished partition map repair on disk4

Command to resize APFS partition (Actually recognizes 2,000,189,177,856 bytes ≈ 2TB)

➜  ~ diskutil apfs resizeContainer disk4s2 0
Started APFS operation
Aligning grow delta to 1,000,194,048,000 bytes and targeting a new container size of 2,000,189,177,856 bytes
Determined the maximum size for the APFS Container to be 2,000,188,149,760 bytes
Resizing APFS Container designated by APFS Container Reference disk5
The specific APFS Physical Store being resized is disk4s2
Verifying storage system
Performing fsck_apfs -n -x /dev/disk4s2
Checking the container superblock
Checking the checkpoint with transaction ID 13537
Checking the space manager
Checking the space manager free queue trees
Checking the object map
Checking volume /dev/rdisk5s2
Checking the APFS volume superblock
The volume TimeMachine was formatted by diskmanagementd (2142.140.9) and last modified by apfs_kext (2236.141.1)
Checking the object map
Checking the snapshot metadata tree
Checking the snapshot metadata
Checking snapshot 1 of 1 (com.apple.TimeMachine.2024-02-22-151317.backup, transaction ID 12340)
Checking the fsroot tree
Checking the extent ref tree
Verifying volume object map space
The volume /dev/rdisk5s2 with UUID 20030003-E683-424F-9C17-173CBF4A58EC appears to be OK
Verifying allocated space
The container /dev/disk4s2 appears to be OK
Storage system check exit code is 0
Growing APFS Physical Store disk4s2 from 999,995,129,856 to 2,000,189,177,856 bytes
Modifying partition map
Growing APFS data structures
Finished APFS operation

GPT Table After Resizing (Unindexed Space from Sector 3907029128 is only 7 blocks now)

➜  ~ sudo gpt show /dev/disk4
       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  3906619488      2  GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
  3907029128           7         
  3907029135          32         Sec GPT table
  3907029167           1         Sec GPT header
ric.row
  • 179