Is it possible to increase size of an APFS volume? I've an APFS disk image (disk3). Currently it's capacity is near close; around 700 MB left.

Is it possible to increase it while keeping the data inside intact!

I've tried diskutil apfs resizeContainer but with no luck.

diskutil list:

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            170.4 GB   disk1s1
   2:                APFS Volume Preboot                 23.1 MB    disk1s2
   3:                APFS Volume Recovery                517.3 MB   disk1s3
   4:                APFS Volume VM                      3.2 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS CAN                     499.7 GB   disk2s2

/dev/disk3 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +30.2 GB    disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                 Apple_APFS Container disk4         29.9 GB    disk3s2

/dev/disk4 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +29.9 GB    disk4
                                 Physical Store disk3s2
   1:                APFS Volume cache                   29.3 GB    disk4s1
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 &lt;size&gt; /path/to/disk_image #&lt;size&gt; 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 &lt;disk_identifier_apfs_container&gt; 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.