Skip to content

Instantly share code, notes, and snippets.

@fzero
Created August 24, 2012 15:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fzero/3451796 to your computer and use it in GitHub Desktop.
Save fzero/3451796 to your computer and use it in GitHub Desktop.
Create a RAM Drive in OS X
#!/bin/bash
# Halt on all errors
set -e
# Check for size parameter and display usage if needed
if [ "$1" == "" ]; then
printf "\nRamdisk - creates a RAM disk (what else?)\n\n"
printf "Usage: ramdisk <size in MB>\n\n"
exit 1
fi
# Drive size = size in MB * block size
SIZE=$(expr $1 \* 2048)
# Do it!
diskutil erasevolume HFS+ "Ramdisk" `hdiutil attach -nomount ram://$SIZE`
#!/bin/bash
# You can use ramdisks for all sorts of things. I personally use it to speed up Ableton Live by
# storing the decoding cache on it. This only works if the disk is always there, which means it needs
# to be re-created every time the computer boots.
#
# To do that, you'll need a second script. This is the one I use.
# Creates a 2Gb ramdisk
/path/to/ramdisk 2048
# Creates the AbletonCache folder (pre-configured in the "Files" pane on Ableton Live preferences)
mkdir -p /Volumes/Ramdisk/AbletonCache
# To make it run on login, use the following command on the terminal (remember to edit the path):
#
# sudo defaults write com.apple.loginwindow LoginHook /path/to/ramdisk_login.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment