5

I'm running a MacPro 5,1 on MacOS 10.14.6 with a 500gb Samsung SSD as my boot/host drive. I recently ran out of space on my 500gb ssd so I speced an identical 1tb ssd.

A clean reinstall is not an option for me so I used clonezilla to do a block copy to the new drive (using newb settings, all defaults). Once the copy was finished and I booted from the new 1tb drive, Disk Utility showed the full 1tb of the physical disk but the APFS container and volume were still both sized at 500gb, completely negating my upgrade =(

This is where it gets weird. I fooled around with this a couple months ago, so I don't remember what I did or where I found documentation for this but somehow, I managed to resize the container to 1tb but the APFS volume size never changed, as I'm still out of usable disk space at 500gb. If it helps, I feel like I vaguely remember using a function of GParted to accomplish this but I don't remember anything outside of that.

How do I fix this? For context, my boot drive is disk2, with the APFS container's physical store located at disk2s2. I've attempted to do a resizeContainer disk2s2 0 hoping it'd somehow realize the mismatch and fix the APFS volume size but with no success. I've also tried a resizeContainer disk2s2 500g with the intention of shrinking the container to 500gb and then retrying the resizeContainer disk2s2 0 to again and properly reclaim the unused 500gb on the drive. I'll show the output of both of those as well as diskutil list, diskutil apfs list (abbreviated, I have alot of other drives lol), and what I'm seeing in Disk Utility.

Any insight is greatly appreciated as I'm in over my head here. Thanks!

$ diskutil list
/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                 Apple_APFS Container disk3         1000.0 GB  disk2s2

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +499.9 GB   disk3
                                 Physical Store disk2s2
   1:                APFS Volume JBax Mac Pro            484.6 GB   disk3s1
   2:                APFS Volume Preboot                 44.5 MB    disk3s2
   3:                APFS Volume Recovery                1.0 GB     disk3s3
   4:                APFS Volume VM                      3.2 GB     disk3s4

$ diskutil apfs list
APFS Container (1 found)
|
+-- Container disk3 C2500AD1-3713-42B3-847F-663C77A85C86
    ====================================================
    APFS Container Reference:     disk3
    Size (Capacity Ceiling):      499898105856 B (499.9 GB)
    Capacity In Use By Volumes:   489041268736 B (489.0 GB) (97.8% used)
    Capacity Not Allocated:       10856837120 B (10.9 GB) (2.2% free)
    |
    +-< Physical Store disk2s2 D63FD546-5CC2-4EB7-B5E7-8DA660BA026B
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk2s2
    |   Size:                       999995133440 B (1000.0 GB)
    |
    +-> Volume disk3s1 66E7E184-D546-4493-854D-92632DF1A94D
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s1 (No specific role)
    |   Name:                      JBax Mac Pro (Case-insensitive)
    |   Mount Point:               /
    |   Capacity Consumed:         484590370816 B (484.6 GB)
    |   FileVault:                 No
    |
    +-> Volume disk3s2 42F434F9-B33D-423F-99C1-F7B04B2EE0C1
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s2 (Preboot)
    |   Name:                      Preboot (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         44486656 B (44.5 MB)
    |   FileVault:                 No
    |
    +-> Volume disk3s3 26827351-189E-4ECB-983F-738A825FAD80
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s3 (Recovery)
    |   Name:                      Recovery (Case-insensitive)
    |   Mount Point:               /Volumes/Recovery 1
    |   Capacity Consumed:         1023565824 B (1.0 GB)
    |   FileVault:                 No
    |
    +-> Volume disk3s4 C571DD11-615E-43CF-BFC0-7FBEC0321EA7
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk3s4 (VM)
        Name:                      VM (Case-insensitive)
        Mount Point:               /private/var/vm
        Capacity Consumed:         3221385216 B (3.2 GB)
        FileVault:                 No

Screenshots from Disk Utility: 1. Disk Utility- Physical Drive 2. Disk Utility- Container

Now here's what happens when trying to manipulate the size of the container:

$ sudo diskutil apfs resizeContainer disk2s2 0
Password:
Started APFS operation
Error: -69519: The target disk is too small for this operation, or a gap is required in your partition map which is missing or too small, which is often caused by an attempt to grow a partition beyond the beginning of another partition or beyond the end of partition map usable space

And here's the second method I tried, attempting to shrink then reclaim:

$ sudo diskutil apfs resizeContainer disk2s2 500g
Started APFS operation
Aligning shrink delta to 499,995,135,488 bytes and targeting a new physical store size of 499,999,997,952 bytes
Determined the minimum size for the targeted physical store of this APFS Container to be 499,898,105,856 bytes
Error: -69605: There is not enough free space in the APFS Container for this operation
0

2 Answers 2

4

I believe the commands you need to enter while in macOS Recovery for Mojave are given below. I would advise reviewing the example, then confirming the values of 409640 and 1953115495 are correct. Also, the identifier for the drive may not be disk2 when booted to macOS Recovery.

gpt -f remove -b 409640 disk2
gpt -f add -b 409640 -s 1953115495 -t apfs disk2
diskutil apfs resizecontainer disk2s2 0

An Example

The objective is to expand the APFS container to the largest possible size, which in this case is the current size of the encompassing APFS partition.

Below are the steps taken to complete the objective.

  1. Restart to macOS Recovery for Mojave.

  2. Open a Terminal window. Enter the command given below to confirm the version is Mojave.

    sw_vers
    

    Sample output is given below.

    ProductName:    Mac OS X
    ProductVersion: 10.14.6
    BuildVersion:   18G103
    
  3. Enter the command below to get the required identifiers.

    diskutil list internal
    

    The sample output below shows the disk0s2 is the identifier for a 1.1 TB APFS partition. A 500.0 GB APFS container with identifier disk1 resides at the beginning of this partition. The container currently has 4 APFS volumes with identifiers disk1s1 through disk1s4.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         1.1 TB     disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +500.0 GB   disk1
                                     Physical Store disk0s2
       1:                APFS Volume Example Mac             19.0 GB    disk1s1
       2:                APFS Volume Preboot                 45.4 MB    disk1s2
       3:                APFS Volume Recovery                510.4 MB   disk1s3
       4:                APFS Volume VM                      20.5 KB    disk1s4
    
  4. Enter the command given below to determine the sector size of the drive and beginning sector of the disk0s2 partition. The Device Block Size is the sector size of the drive in bytes. The Partition Offset in bytes divided by the sector size of the drive in bytes equals the beginning sector of the disk0s2 partition.

    diskutil info disk0s2 | grep  -e Offset -e "Block Size"
    

    The output below shows the sector size of the drive is 512 bytes and 409640 is the beginning sector of the disk0s2 partition.

       Partition Offset:          209735680 Bytes (409640 512-Byte-Device-Blocks)
       Device Block Size:         512 Bytes
    

    Note: If the Device Block Size is 4096 bytes, then the Partition Offset in 512-Byte-Device-Blocks would need to be divided by 8 in order to determine the beginning sector of the disk0s2 partition.

  5. Enter the command given below to determine size of the disk1 container in sectors. In this example, the disk1s1 volume was specified. Actually, the identifier of any volume in the disk1 container can be substituted. The Disk Size in bytes divided by the sector size of the drive in bytes equals the size in sectors of disk1 container.

    diskutil info disk1s1 | grep "Disk Size"
    

    The output below shows the disk1 container is 976562496 sectors in size.

       Disk Size:                 500.0 GB (499999997952 Bytes) (exactly 976562496 512-Byte-Units)
    

     

    Note: If the Device Block Size from the previous step is 4096 bytes, then the Disk Size in 512-Byte-Device-Blocks would need to be divided by 8 in order to determine the size in sectors of the disk1 container.

    Alternate method to determine the size in sectors of the disk1 container

    This alternate method would be useful when there are no volumes in the container. Enter the command given below to determine the Size (Capacity Ceiling) in bytes, which is also the size in bytes of the disk1 container.

    diskutil apfs list disk1 | grep Ceiling
    

    The sample output below shows the size of the disk1 container is 499999997952 bytes / 512 bytes per sector = 976562496 sectors.

        Size (Capacity Ceiling):      499999997952 B (500.0 GB)
    
  6. Enter the following two commands to change the size of the disk0s2 partition to the size of the disk1 container. The first command is given below. This command removes the disk0s2 partition from the GUID Partition Table (GPT) for the disk0 drive. The value of 409640 is the beginning sector of the disk0s2 partition determined in step 4.

    gpt -f remove -b 409640 disk0
    

    Sample output is given below.

    disk0s2 removed
    

    Note: The disk0s2 shown above can differ from the disk0s2 produced by the diskutil command. The disk0s2 from diskutil means slice 2 of disk0 and the disk0s2 from gpt means 2 is the index of the entry in GUID Partition Table (GPT) for disk0. In other words, the slice number does not have to match the index of the GPT table entry. In this example, the two match, which is usually the case.

    In this example, the disk1s1 and disk1s3 volumes remain mounted even though the encompassing disk0s2 partition no longer exists in the GPT for disk0. The second command is given below. This command adds the disk0s2 partition back in to the GPT for the disk0 drive. The value of 409640 is the beginning sector of the disk0s2 partition determined in step 4. The value of 976562496 is the size in sectors of the disk1 container determined in step 5.

    gpt -f add -b 409640 -s 976562496 -t apfs disk0
    

    Sample output is given below.

    disk0s2 added
    

    Note: The indices output from the above two gpt commands can differ. In this example, the two match, which is usually the case.

  7. Enter the command below to confirm the disk0s2 partition now matches the disk1 container in size.

    diskutil list internal
    

    The sample output below shows the disk0s2 partition and the disk1 container are both 500.0 GB in size.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         500.0 GB   disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +500.0 GB   disk1
                                     Physical Store disk0s2
       1:                APFS Volume Example Mac             19.0 GB    disk1s1
       2:                APFS Volume Preboot                 45.4 MB    disk1s2
       3:                APFS Volume Recovery                510.4 MB   disk1s3
       4:                APFS Volume VM                      20.5 KB    disk1s4
    
  8. Enter the command given below to expand the disk0s2 partition and disk1 container to the largest possible size. For this command to work, the change must be sufficiently large, which is true in this example.

    diskutil apfs resizecontainer disk0s2 0
    

    Sample output is shown below.

    Started APFS operation
    Aligning grow delta to 573,532,069,888 bytes and targeting a new physical store size of 1,073,532,067,840 bytes
    Determined the maximum size for the targeted physical store of this APFS Container to be 1,073,531,039,744 bytes
    Resizing APFS Container designated by APFS Container Reference disk1
    The specific APFS Physical Store being resized is disk0s2
    Verifying storage system
    Using live mode
    Performing fsck_apfs -n -x -l -S /dev/disk0s2
    Checking the container superblock
    Checking the EFI jumpstart record
    Checking the space manager
    Checking the space manager free queue trees
    Checking the object map
    Checking volume
    Checking the APFS volume superblock
    The volume Example Mac was formatted by diskmanagementd (945.275.7) and last modified by apfs_kext (945.275.7)
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the extent ref tree
    Checking the fsroot tree
    Checking volume
    Checking the APFS volume superblock
    The volume Preboot was formatted by diskmanagementd (945.275.7) and last modified by apfs_kext (945.275.7)
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the extent ref tree
    Checking the fsroot tree
    Checking volume
    Checking the APFS volume superblock
    The volume Recovery was formatted by diskmanagementd (945.275.7) and last modified by apfs_kext (945.275.7)
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the extent ref tree
    Checking the fsroot tree
    Checking volume
    Checking the APFS volume superblock
    The volume VM was formatted by apfs.util (945.275.7) and last modified by apfs_kext (945.275.7)
    Checking the object map
    Checking the snapshot metadata tree
    Checking the snapshot metadata
    Checking the extent ref tree
    Checking the fsroot tree
    Verifying allocated space
    The volume /dev/disk0s2 appears to be OK
    Storage system check exit code is 0
    Growing APFS Physical Store disk0s2 from 499,999,997,952 to 1,073,532,067,840 bytes
    Modifying partition map
    Growing APFS data structures
    Finished APFS operation
    

    Enter the command below to confirm the disk0s2 partition and disk1 container are now both 1.1 TB in size.

    diskutil list internal
    

    Sample output is given below.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         1.1 TB     disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +1.1 TB     disk1
                                     Physical Store disk0s2
       1:                APFS Volume Example Mac             19.0 GB    disk1s1
       2:                APFS Volume Preboot                 45.4 MB    disk1s2
       3:                APFS Volume Recovery                510.4 MB   disk1s3
       4:                APFS Volume VM                      20.5 KB    disk1s4
    
  9. Restart back to macOS.

1
  • Great answer, thank you! This should be marked as the right answer.
    – Sai
    Dec 18, 2023 at 10:18
3

APFS volumes resize automatically. The container shows 1000GB, ie the entire drive, give or take; the Volume should show the currently-used space. That you previously ran out of space makes it look about right.

This is mine… [same Mac Pro, same OS, disk mounted on PCI card which makes it think it's external]

/dev/disk6 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk6
   1:                        EFI EFI                     209.7 MB   disk6s1
   2:                 Apple_APFS Container disk7         998.2 GB   disk6s2
   3:                  Apple_HFS eDrive                  25.6 GB    disk6s3

/dev/disk7 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +998.2 GB   disk7
                                 Physical Store disk6s2
   1:                APFS Volume KickMeHard              401.8 GB   disk7s1
   2:                APFS Volume Preboot                 21.2 MB    disk7s2
   3:                APFS Volume VM                      20.5 KB    disk7s3
   4:                APFS Volume Recovery                507.6 MB   disk7s4
7
  • Gotcha. I was curious why the pci cards always displayed as 'external' drives. It doesn't seem like the volume automatically resized though. MacOs keeps throwing me warning messages 'You're low on disk space' and 'You have x amount of space left' so I keep having to work around the 500gb volume even though it's in a 1tb container. Oct 15, 2021 at 19:00
  • Ah, my bad. I bet it's because the 3 additional volumes are butted up tight against the first, at the 500GB mark - hence the Error: -69519 on your first attempt. I'm not sure how to get out of that [though I don't think it's impossible, just above my paygrade;)
    – Tetsujin
    Oct 16, 2021 at 7:34
  • I've actually avoided this in the past by using Carbon Copy Cloner. Format new drive, CCC to it, you get the new size. [I've actually been doing this for so long that all the Macs in the building are a hereditary fork of my first Mac Pro in 2008;)
    – Tetsujin
    Oct 16, 2021 at 7:36
  • Man, I feel you. Most of my machines share lineage from cloning an old Sony Vaio laptop's Windows install so many times (first nice machine I ever owned) ;-). I'll give CCC a shot. Any specific parameters to adhere too? Only as of couple years ago have I started to maintain a fleet of Macs so APFS and other little quirks of OSX and BSD are still a bit of a dark art to me. Oct 16, 2021 at 13:06
  • 1
    Sweet!!! Thank you so much for sharing all this. Looks like I got some homework to do here. I'll update you, whatever the outcome. Thanks again, I appreciate you taking the time help out some random yank from Georgia =) Oct 16, 2021 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .