Skip to content

Instantly share code, notes, and snippets.

Last active November 9, 2022 07:29
What would you like to do?
Move Chrome, Safari and iTunes Cache to Ramdisk.
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
# Chrome Cache
/bin/rm -rvf ~/Library/Caches/Google/Chrome/*
/bin/mkdir -pv $CACHEDIR/Google/Chrome/Default
/bin/ln -v -s $CACHEDIR/Google/Chrome/Default ~/Library/Caches/Google/Chrome/Default
# Chrome Canary Cache
/bin/rm -rvf ~/Library/Caches/Google/Chrome\ Canary/*
/bin/mkdir -pv $CACHEDIR/Google/Chrome\ Canary/Default
/bin/ln -v -s $CACHEDIR/Google/Chrome\ Canary/Default ~/Library/Caches/Google/Chrome\ Canary/Default
# Safari Cache
/bin/rm -rvf ~/Library/Caches/
/bin/mkdir -pv $CACHEDIR/Apple/Safari
/bin/ln -v -s $CACHEDIR/Apple/Safari ~/Library/Caches/
# iTunes Cache
/bin/rm -rvf ~/Library/Caches/
/bin/mkdir -pv $CACHEDIR/Apple/iTunes
/bin/ln -v -s $CACHEDIR/Apple/iTunes ~/Library/Caches/
# Spotify Cache
/bin/rm -rvf ~/Library/Caches/com.spotify.client
/bin/mkdir -pv $CACHEDIR/Spotify
/bin/ln -v -s $CACHEDIR/Spotify ~/Library/Caches/com.spotify.client
/usr/bin/chflags hidden /Volumes/RamDiskCache #Hide RamDisk directory
Copy link

Found the answer using diskutil info $DISK

Total Size:               1.1 GB (1073741824 Bytes) (exactly 2097152 512-Byte-Units)

Copy link

blk-swn commented Jun 6, 2017

Hi I'm wondering if I put this script in my ~/Library/StartupItems directory, will it run at startup?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment