I took a full backup of the drive to another external drive (I did it this way to preserve all extended attributes etc), just to be safe:
hdiutil create -verbose -srcfolder /Volumes/Macintosh HD/ /Volumes/MyPassport/RandoBackups/everything.dmg
Once that was complete (a very long time, like 18 hours), I took a look at the current Volume layout on the drive:
Admins-MacBook-Air:~ root#diskutil apfs list
APFS Container (1 found)
|
+-- Container disk1 27506B8B-768F-47C4-ADC0-56389DE1664C
====================================================
APFS Container Reference: disk1
Capacity Ceiling (Size): 500068036608 B (500.1 GB)
Capacity In Use By Volumes: 500067958784 B (500.1 GB) (100.0% used)
Capacity Available: 77824 B (77.8 KB) (0.0% free)
|
+-< Physical Store disk0s2 A7216C52-8F02-485E-94C0-2C00D8B4EC9B
| -----------------------------------------------------------
| APFS Physical Store Disk: disk0s2
| Size: 500068036608 B (500.1 GB)
|
+-> Volume disk1s1 D02FB47F-49D6-3F4B-A6DF-2A675B1DF573
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s1 (No specific role)
| Name: Macintosh HD (Case-insensitive)
| Mount Point: /Volumes/Macintosh HD
| Capacity Consumed: 492922859520 B (492.9 GB)
| FileVault: Yes (Unlocked)
|
+-> Volume disk1s2 BC7A96D4-8914-4E48-9C1C-B09AF434D32A
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s2 (Preboot)
| Name: Preboot (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 20566016 B (20.6 MB)
| FileVault: No
|
+-> Volume disk1s3 6E4241B7-322C-4FAC-BB96-549FCDE9C607
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s3 (Recovery)
| Name: Recovery (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 509820928 B (509.8 MB)
| FileVault: No
|
+-> Volume disk1s4 FDFD2987-D9D2-4493-AB2E-3D59812A3579
---------------------------------------------------
APFS Volume Disk (Role): disk1s4 (VM)
Name: VM (Case-insensitive)
Mount Point: Not Mounted
Capacity Consumed: 6453272576 B (6.5 GB)
FileVault: No
I then removed the VM (Virtual Memory) volume (disk1s4):
Admins-MacBook-Air:~ root#diskutil apfs deleteVolume disk1s4
Started APFS operation
Deleting APFS Volume from its APFS Container
Unmounting disk1s4
Deleting Volume
Finished APFS operation
Admins-MacBook-Air:~ root#diskutil apfs list
APFS Container (1 found)
|
+-- Container disk1 27506B8B-768F-47C4-ADC0-56389DE1664C
====================================================
APFS Container Reference: disk1
Capacity Ceiling (Size): 500068036608 B (500.1 GB)
Capacity In Use By Volumes: 493614673920 B (493.6 GB) (98.7% used)
Capacity Available: 6453362688 B (6.5 GB) (1.3% free)
|
+-< Physical Store disk0s2 A7216C52-8F02-485E-94C0-2C00D8B4EC9B
| -----------------------------------------------------------
| APFS Physical Store Disk: disk0s2
| Size: 500068036608 B (500.1 GB)
|
+-> Volume disk1s1 D02FB47F-49D6-3F4B-A6DF-2A675B1DF573
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s1 (No specific role)
| Name: Macintosh HD (Case-insensitive)
| Mount Point: /Volumes/Macintosh HD
| Capacity Consumed: 492922851328 B (492.9 GB)
| FileVault: Yes (Unlocked)
|
+-> Volume disk1s2 BC7A96D4-8914-4E48-9C1C-B09AF434D32A
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s2 (Preboot)
| Name: Preboot (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 20566016 B (20.6 MB)
| FileVault: No
|
+-> Volume disk1s3 6E4241B7-322C-4FAC-BB96-549FCDE9C607
---------------------------------------------------
APFS Volume Disk (Role): disk1s3 (Recovery)
Name: Recovery (Case-insensitive)
Mount Point: Not Mounted
Capacity Consumed: 509820928 B (509.8 MB)
FileVault: No
I could then delete a bunch of stuff off the drive - yay! I then deleted a bunch of stuff (the Finder did not show this as free space yet).
After deleting a bunch of things, I went about restoring the VM volume (note the free space in the list command after adding the volume looks a lot better):
Admins-MacBook-Air:~ root#diskutil apfs addVolume disk1 APFS VM -role V -nomount
Exporting new unencrypted APFS Volume "VM" from APFS Container Reference disk1
Started APFS operation on disk1
Preparing to add APFS Volume to APFS Container disk1
Creating APFS Volume
Created new APFS Volume disk1s4
Disk from APFS operation: disk1s4
Finished APFS operation on disk1
Admins-MacBook-Air:~ root#diskutil apfs list
APFS Container (1 found)
|
+-- Container disk1 27506B8B-768F-47C4-ADC0-56389DE1664C
====================================================
APFS Container Reference: disk1
Capacity Ceiling (Size): 500068036608 B (500.1 GB)
Capacity In Use By Volumes: 436513718272 B (436.5 GB) (87.3% used)
Capacity Available: 63554318336 B (63.6 GB) (12.7% free)
|
+-< Physical Store disk0s2 A7216C52-8F02-485E-94C0-2C00D8B4EC9B
| -----------------------------------------------------------
| APFS Physical Store Disk: disk0s2
| Size: 500068036608 B (500.1 GB)
|
+-> Volume disk1s1 D02FB47F-49D6-3F4B-A6DF-2A675B1DF573
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s1 (No specific role)
| Name: Macintosh HD (Case-insensitive)
| Mount Point: /Volumes/Macintosh HD
| Capacity Consumed: 435821875200 B (435.8 GB)
| FileVault: Yes (Unlocked)
|
+-> Volume disk1s2 BC7A96D4-8914-4E48-9C1C-B09AF434D32A
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s2 (Preboot)
| Name: Preboot (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 20566016 B (20.6 MB)
| FileVault: No
|
+-> Volume disk1s3 6E4241B7-322C-4FAC-BB96-549FCDE9C607
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s3 (Recovery)
| Name: Recovery (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 509820928 B (509.8 MB)
| FileVault: No
|
+-> Volume disk1s4 27B81A49-FCD0-4521-9E8B-7168E767892E
---------------------------------------------------
APFS Volume Disk (Role): disk1s4 (VM)
Name: VM (Case-insensitive)
Mount Point: Not Mounted
Capacity Consumed: 20480 B (20.5 KB)
FileVault: No
And then finally, to make sure it does not happen again, I created a Volume with a 1GB quota (this means there should always be 1GB of space available, so worst case, I can just delete this partition should it happen again):
Admins-MacBook-Air:~ root#diskutil apfs addVolume disk1 APFS space -reserve 1000000000 -nomount
Exporting new unencrypted APFS Volume "space" from APFS Container Reference disk1 with a 1000000000-byte reserve
Started APFS operation on disk1
Preparing to add APFS Volume to APFS Container disk1
Creating APFS Volume
Created new APFS Volume disk1s5
Disk from APFS operation: disk1s5
Finished APFS operation on disk1
Admins-MacBook-Air:~ root#diskutil apfs list
APFS Container (1 found)
|
+-- Container disk1 27506B8B-768F-47C4-ADC0-56389DE1664C
====================================================
APFS Container Reference: disk1
Capacity Ceiling (Size): 500068036608 B (500.1 GB)
Capacity In Use By Volumes: 437513744384 B (437.5 GB) (87.5% used)
Capacity Available: 62554292224 B (62.6 GB) (12.5% free)
|
+-< Physical Store disk0s2 A7216C52-8F02-485E-94C0-2C00D8B4EC9B
| -----------------------------------------------------------
| APFS Physical Store Disk: disk0s2
| Size: 500068036608 B (500.1 GB)
|
+-> Volume disk1s1 D02FB47F-49D6-3F4B-A6DF-2A675B1DF573
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s1 (No specific role)
| Name: Macintosh HD (Case-insensitive)
| Mount Point: /Volumes/Macintosh HD
| Capacity Consumed: 435821875200 B (435.8 GB)
| FileVault: Yes (Unlocked)
|
+-> Volume disk1s2 BC7A96D4-8914-4E48-9C1C-B09AF434D32A
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s2 (Preboot)
| Name: Preboot (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 20566016 B (20.6 MB)
| FileVault: No
|
+-> Volume disk1s3 6E4241B7-322C-4FAC-BB96-549FCDE9C607
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s3 (Recovery)
| Name: Recovery (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 509820928 B (509.8 MB)
| FileVault: No
|
+-> Volume disk1s4 27B81A49-FCD0-4521-9E8B-7168E767892E
| ---------------------------------------------------
| APFS Volume Disk (Role): disk1s4 (VM)
| Name: VM (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 20480 B (20.5 KB)
| FileVault: No
|
+-> Volume disk1s5 80D5032A-B896-42AF-937F-308DA740A782
---------------------------------------------------
APFS Volume Disk (Role): disk1s5 (No specific role)
Name: space (Case-insensitive)
Mount Point: Not Mounted
Capacity Consumed: 1000001536 B (1.0 GB)
Capacity Reserve: 1000001536 B (1.0 GB)
Capacity Quota: None
FileVault: No
Then after all of the above, things were looking good with a disk check:
Admins-MacBook-Air:~ root#diskutil unmount /dev/rdisk1s1
Volume Macintosh HD on disk1s1 unmounted
Admins-MacBook-Air:~ root#diskutil apfs unlockVolume /dev/rdisk1s1 -nomount
Passphrase:
Unlocking any cryptographic user on APFS Volume disk1s1
Unlocked but did not mount APFS Volume
Admins-MacBook-Air:~ root#fsck_apfs -d /dev/rdisk1s1
** Checking volume.
** Checking the container superblock.
** Checking the EFI jumpstart record.
** Checking the space manager.
** Checking the object map.
** Checking the APFS volume superblock.
** Checking the object map.
dev_init:464: Using /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/fsck_apfs.45833/apfs and /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/fsck_apfs.45833/nx for device-io.
** Checking the fsroot tree.
** Checking the snapshot metadata tree.
** Checking the extent ref tree.
** Checking the snapshots.
** Verifying allocated space.
** The volume /dev/rdisk1s1 appears to be OK.
Yay!