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?
Best Answer
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 alimits
option fordiskutil resizeVolume
anddiskutil 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.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.
I used the math below to compute the size of the NTFS partition.
I used the math below to compute the size of the APFS partition
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.
diskutil
,gpt
orgdisk
.Create a new APFS partition to include the free space. You can do this with with
gpt
orgdisk
.Format the new partition. You can do this with with the Disk Utility applications,
diskutil
, ornewfs_apfs
.