Is it possible to increase size of an APFS volume?
Solution 1:
You can first increase the size of the disk image and in a second step the size of the container:
-
Get the disk image limits:
hdiutil resize -limits /path/to/disk_image
-
Eject the disk image items:
diskutil list diskutil eject diskXsY #eject all volumes/items of the image
-
Depending on the limits increase the size of the image:
hdiutil resize -size <size> /path/to/disk_image #<size> in b|k|m|g|t (e.g. 50g)
This works for normal as well as sparse images. I didn't test sparse bundle images.
-
Mount the disk image:
hdiutil attach /path/to/disk_image
-
Get the details:
diskutil list
-
Increase the size of the APFS container:
diskutil apfs resizeContainer <disk_identifier_apfs_container> 0
Don't mix the disk identifiers of SSD and disk image APFS container here! The embedded APFS volume should be expanded automatically if required.
Using certain APFS formatted disk images (sparse images) may result in data loss in the image on APFS formatted physical disks with low free space.
Instead of using an APFS disk image simply create a new APFS cache volume (with quota?) in the APFS container (internal SSD) or an image/a second partition on an external HDD.