I have a 500GB SSD with a 280GB NTFS volume, and a 180GB APFS container. The output from diskutil and gdisk are below.

I resized the NTFS volume to 280GB from 300GB using the disk mgmt MMC in Win7. The GPT clearly shows the volume as 280GB. However both DiskUtility and diskutil show it as 300GB.

I want to grow the APFS container by that 20GB to regain the space on the OSX side. diskutil/APFS complains there's no extra space.

Per gdisk, the GPT is fine and healthy, and it's a 465GB usable disk, with 20GB spare on it. gpt v shows the below, which confirms there's 20GB unused somewhere:

No problems found. 40529892 free sectors (19.3 GiB) available in 3
segments, the largest of which is 40527872 (19.3 GiB) in size.

Full command output -

$ diskutil list
/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk2
   1:         Microsoft Reserved                         134.2 MB   disk2s1
   2:       Microsoft Basic Data Win Data                301.4 GB   disk2s2
   3:                 Apple_APFS Container disk4         177.9 GB   disk2s3
$ sudo gdisk /dev/disk2
Command (? for help): p
Disk /dev/disk2: 976773168 sectors, 465.8 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 04004F01-0E37-40FE-9832-C26943A645C3
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 40529892 sectors (19.3 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34          262177   128.0 MiB   0C01  Microsoft reserved ...
   2          264192       588881912   280.7 GiB   0700  Win Data
   3       629409785       976773128   165.6 GiB   AF0A  Mac Data
$ sudo diskutil apfs resizeContainer /dev/disk2s3 0
Started APFS operation
Error: -69743: The new size must be different than the existing size

So - how can I get macOS (High Sierra) to actually acknowledge there's 20GB spare here and use it?


Note: I assume disk2 has a protective MBR which means the drive is not using a GPT/MBR hybrid partitioning scheme. The gdisk command displays the type of partitioning when first invoked, but in your question you choose to omit this output.

Question: How can I get macOs to actually acknowledge there's 20GB free space?

The Disk Utility application assumes there is never any significant free space on any drive. All successful operations performed using this application always leave the drive with no significant free space.

Of course, drives often have free space. In fact, you can create free space using the diskutil command. Therefore, the Disk Utility application can/should only be used under ideal conditions.

The diskutil list command has never shown free space. There is a limits option for diskutil resizeVolume and diskutil apfs resizeContainer that will display the amount of space that a partition can be expanded into. One can assume this is free space below the said partition.

One command included with macOS, that will show free space, is the gpt command. In your case, you would enter the command given below.

sudo gpt -r show /dev/disk2

The output from gdisk, shown in your question, produced basically the same information the above command would produce.

I used the math below to compute the free space.

629,409,785 - 588,881,912 - 1 = 40,527,872 sectors 
40,527,872 sectors * 512 bytes/sector = 20,750,270,464 bytes = 20.8 GB
20.8 GB * 0.931323 GiB/GB = 22.3 GiB

I used the math below to compute the size of the NTFS partition.

588,881,912 - 264,192 + 1 = 588,617,721 sectors
588,617,721 * 512 bytes/sector = 301,372,273,152 bytes = 301.4 GB
301.4 GB * 0.931323 GiB/GB = 280.7 GiB

Note: This is the same result the output from diskutil and gdisk show in your question. There is no error here. The problem may be in the way Windows 7 is labeling the partition sizes. Windows 7 may have mislabeled GB for GiB or vice versa.

I used the math below to compute the size of the APFS partition

976773128 - 629409785 + 1 = 347,363,344 sectors
347,363,344 sectors * 512 bytes/sector =  177,850,032,128 bytes = 177.9 GB
177.9 GB * 0.931323 GiB/GB = 165.7 GiB

Note: 1 GB = 1,000,000,000 bytes and 1 GiB = 1,073,741,824 bytes.

Question: How can I get macOs to add the 20 GB of free space to the APFS partition?

You don't. You can add free space immediately after a APFS partition but not free space immediately before. In your case, the free space is before the APFS partition.

Technically, you could first move the APFS partition to the start of the free space, causing the free space to be below the APFS partition. This would allow you to use the diskutil apfs resizeContainer command to add the free space.

Third party software exists that claims to be able move a partition. I tried using a bootable USB flash drive containing GParted to move a APFS partition, only to discover GParted does not recognize the APFS format and therefore will not move this type of partition. (To create a bootable USB flash drive containing GParted, I used UNetbootin to transfer the GParted ISO to the flash drive.)

Another option would require another drive with enough free space. The steps are given below.

  1. Backup the APFS partition to another drive.
  2. Delete the APFS partition. You can do this with with diskutil, gpt or gdisk.
  3. Create a new APFS partition to include the free space. You can do this with with gpt or gdisk.

    Note: Make sure the sector values you enter are divisible by 8.

  4. Format the new partition. You can do this with with the Disk Utility applications, diskutil, or newfs_apfs.

  5. Restore from the backup drive.

You must log in to answer this question.

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