Persistent RAMDisk

Works on macOS Big Sur.



There is a non-deprecated way to do it:

do shell script "~/.login"

on quit
	do shell script "~/.logout"
	continue quit
end quit

To hide it from the Dock:


Create RAMDisk scripts

$ touch ~/.login
$ touch ~/.logout
$ chmod +x ~/.login
$ chmod +x ~/.logout

Open ~/.login and paste, this creates a 1GB RAMDisk

#!/usr/bin/env bash
diskutil erasevolume HFS+ "RAMDisk" `hdiutil attach -nomount ram://2097152` && rsync -rauL --ignore-errors ~/.RAMDisk/ /Volumes/RAMDisk

Open ~/.logout and paste

#!/usr/bin/env bash
rsync -rauL --delete --ignore-errors /Volumes/RAMDisk/ ~/.RAMDisk

Example use: PHPStorm caches on RAMDisk

  1. Create a folder called PHPStorm on the RAMDisk.
  2. Start PHPStorm > Help > Edit custom properties... and paste