Skip to content

Instantly share code, notes, and snippets.

@sohooo
Created June 30, 2012 13:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sohooo/3023740 to your computer and use it in GitHub Desktop.
Save sohooo/3023740 to your computer and use it in GitHub Desktop.
create RAM disk in OS X
#!/bin/bash
#
# Create a RAM Disk in Mac OS X 10.5, 10.6, 10.7 or later.
# To remove the RAM disk, simply eject it from the desktop
# as you would any other disk.
#
# http://osxdaily.com/2007/03/23/create-a-ram-disk-in-mac-os-x/
if [ -z "$1" ]; then
echo Usage: $0 SIZE_IN_MB
exit 1
fi
MB_SIZE=$1
# The `hdiutil` wants the number in form of 512K blocks.
# However, we'd like to use values in MB.
let "MB_SIZE *= 2048"
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://${MB_SIZE}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment