Summary
Non-empty APFS volumes with 'Reserve Size' prevent containers from creating other 'Reserve Size' volumes.
Description
When calculating the free space available inside a container, diskutil/Disk Utility.app seem to remove the entirety of the reserve size PLUS the entirety of the used size.
I would expect instead to remove the max(reserve size, used size).
Note
This disk is not backed up by Time Machine and has no local Snapshots. That is not the issue. I checked.
Steps
- start with 1TB external HD
- format as APFS, delete any volume if created automatically.
- create a first volume 'VolumeA', with 500 GB Reserve Size and no quota. Should succeed.
- create a second volume 'VolumeB', with 500 GB Reserve Size and no quota. Should succeed.
- delete VolumeB, inspect available size on Container, find 500 GB
- use 100GB on VolumeA with random data using command
dd if=/dev/urandom of=/Volumes/VolumeA/HundredGBFile bs=100000000 count=1000
- now try recreating the same VolumeB as in step 4, with 500 GB reserve. This fails for me in 10.15.7/11.4, with an error There is not enough free space in this APFS Container for this operation. : (-69605)
- run 'diskutil apfs list' and notice that the Container's Capacity In Use By Volumes: is now 600 GB, even though the VolumeA is clearly only using 100 GB, not 600
Conclusion
In the current version of the OS, if one wants to use multiple volumes with 'Reserve Size' enabled to reserve most of the space available in their container, volumes mayneed to be created before the data written to disk is larger that the total non reserved space.
This is an edge case for most users, but I still think the calculation of the amount of free space at the container level is currently wrong and should be fixed.