Skip to content

Instantly share code, notes, and snippets.

@fzero
Created Aug 24, 2012
Embed
What would you like to do?
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