MacOS – OS will not mount the VM partition. Virtual memory must be forced to work

mac promacospartitionvirtual-memory

Virtual memory was broken on my Mac (cMP 5.1) for several months, with Sierra, High Sierra, and Mojave. Apple support was useless.

I finally figured out that I was missing all the invisible partitions on the boot drive (vm, recovery, etc.). Probably a casualty of a Carbon Copy Cloner mistake. But CCC allowed me to restore the partitions from a backup.

Still, the system doesn't use the vm partition. I can get it to work manually with sudo diskutil mount -mountPoint /private/var/vm disk1s4, but it doesn't remember this after a restart.

Any ideas on a permanent fix?

Best Answer

Solved. Cobbled together a workaround with information from interwebs.

Created this plist named “local.mountdisk1s4.plist” containing:

Label local.mountdisk1s4.plist ProgramArguments /sbin/mount_apfs disk1s4 /private/var/vm KeepAlive SuccessfulExit

Placed it in /Library/launchdaemons

Swapping now works as it should. Still not sure how this all broke in the first place, or if there's a more elegant solution.