What is the difference between “/private/var/vm” and “/vm”?

I’m wondering why my Mac (running macOS High Sierra 10.13.6) has both /private/var/vm and /vm:

$ ls -l /private/var/vm /vm
/private/var/vm:
total 4194304
-rw------T  1 root  wheel  1073741824 May 17 19:12 sleepimage
-rw-------  1 root  wheel  1073741824 May 26 13:29 swapfile0

/vm:
total 2097152
-rw-------  1 root  wheel  1073741824 May 14 23:49 swapfile0

I know these have to do with virtual memory, but why are there two of them; what's the difference?

Are both of the files named swapfile0 being used or can I delete one? I assume that if I would delete one, it would be the second one, as it hasn’t been modified in over a week, whereas the first one was modified only a few minutes ago (I rebooted my Mac just now). But how can I tell for sure whether it is safe to delete? Why does it exist to begin with?


Solution 1:

This happens because of a change that happened within the High Sierra versions. It is unknown whether this is a bug, or simply a change of hearts at Apple, but with High Sierra the location of the swapfile was changed from /private/var/vm to /vm, and then in a later update to High Sierra moved back to /privat/var/vm.

The best way to proceed is to ensure that you have upgraded to the latest High Sierra version. If the extraneous swapfile in /vm/swapfile0 still exists and takes up disk space, then boot up in Recovery Mode, use Disk Utility to mount the main volume, and start a Terminal and run: (replace TheVolumeName with the name of the main volume)

rm /Volumes/TheVolumeName/vm/swapfile0

Then you can reboot afterwards.