macOS Catalina move caches and logs to RAMdisk
In a previous post I wrote about how I monitor the writes to several SSD’s.
To avoid this I wrote a shell script that removes the cache folders, creates them on a RAM disk and creates symlinks for them so the applications don’t know it’s even happening.
The first file is the shell script that does the actual work:
That file is executed on system startup by a LaunchAgent, the file is stored as /Library/LaunchAgents/com.user.ramdisk.plist
Of course the LaunchAgent has to be enabled:
launchctl enable /Library/LaunchAgents/com.user.ramdisk.plist
After this, reboot your Mac and watch the RamDisk to see if everything’s working:
Within less than one hour it saved more than 700MB writes (The Google folder gets constantly written, the size doesn’t represent the real save).
Time to search how we can actually see how much is written to the RAM disk, there must be something we can do with iostat for that.
iostat -Id disk2
guy@Mars2020 ~ % sudo iostat -Id disk2
KB/t xfrs MB
24.37 153324 3648.93
Instead of saving a meager 700MB, we saved 3648MB of disk writes.
If you have other folders that could be on a RAM disk let me know in the comments.