MacOS – APFS Volume Total Shows Less Free Space Than Container and How to Reclaim Space

apfsbootcampdisk-utilityhard drivemacos

So I have a bootcamp volume which has windows installed on it. I used MiniTool partition wizard to shrink the bootcamp size from 60 GB to 40 GB to reclaim 20 GB for my Macintosh HD.

That operation successfully executed and as you will see, container for APFS is at 190 GB now. But my Macintosh HD is still occupying 165.4 GB. I tried resizing using (/usr/sbin/diskutil apfs resizeContainer /dev/disk1 0) but to no avail. Does anyone know how I can reclaim the 20 GB space I freed up before and use container to its max capacity?

What surprises me a little is that this freed 20 GB doesn't show up in UI of disk utility but can be noticed in cmd output of diskutil list:

enter image description here

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         190.0 GB   disk0s2
   3:         Microsoft Reserved                         134.2 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                42.9 GB    disk0s4
   5:           Windows Recovery                         471.9 MB   disk0s5

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +190.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            165.4 GB   disk1s1
   2:                APFS Volume Preboot                 21.1 MB    disk1s2
   3:                APFS Volume Recovery                519.0 MB   disk1s3
   4:                APFS Volume VM                      2.1 GB     disk1s4

Thank you so much for all your help in advance!

Best Answer

The results from the math shown below is about 17.3 GB of unallocated space.

 250.0     Total drive space
   -.2907  EFI partition
-190.0     APFS container
   -.1342  Microsoft Reserved
 -42.9     BOOTCAMP
   -.4719  Windows Recovery
_________
  17.2842  Unallocated space

I assume this unallocated space is between the Apple_APFS and Microsoft Reserved partitions. If so, then the correct command to add the free space to the Apple_APFS partition is given below. Before using this command, open the MiniTool application and confirm the free space is between the Apple_APFS and Microsoft Reserved partitions.

sudo diskutil apfs resizeContainer disk0s2 0

From the information you posted, I am guessing the free space will between the Microsoft Reserved and Microsoft Basic Data partitions. If this is the case, then you will first need to move the Microsoft Reserved partition partition to the end of the free space. Below is an outline of the steps to follow.

  1. The MiniTool can not move this partition. Instead you can make a copy of the partition.
  2. The copy of the Microsoft Reserved partition will have the wrong partition type id. You will need to use the MiniTool application to change this id to Windows - Microsoft Reserved Partition.
  3. The new partition will need to be assigned the GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER attribute bit. Basically, this is bit 0x8000000000000000. Unfortunately, this can to be done using MiniTool. You will have to use the diskpart command from a Administrator Command Prompt window.
  4. After exiting diskpart, you will need to reboot Windows.
  5. Use the MiniTool to remove the original Microsoft Reserved partition.

A final note:

You posted the following question.

That operation successfully executed and as you will see, container for APFS is at 190 GB now. But my Macintosh HD is still occupying 165.4 GB. I tried resizing using (/usr/sbin/diskutil apfs resizeContainer /dev/disk1 0) but to no avail. Does anyone know how I can reclaim the 20 GB space I freed up before and use container to its max capacity?

Answer: Basically, the question makes no sense. The APFS container has a size of 190 GB and the Macintosh HD volume is using 165.4 GB of this container's space. If you enlarge the APFS container, the size of the Macintosh HD volume will not change.