Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created July 4, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgmoose/028bb1346b09d4b1a695 to your computer and use it in GitHub Desktop.
Save vgmoose/028bb1346b09d4b1a695 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -ne 1 ]
then
echo "Usage: ramdisk size_in_MB"
exit 1
fi
if [[ $OSTYPE == *"linux"* ]]
then
mkdir /mnt/ramdisk
mount -t tmpfs -o size=$1m tmpfs /mnt/ramdisk
fi
if [[ $OSTYPE == *"darwin"* ]]
then
diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://$(($1*2048))`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment