ramdisk.sh:
#!/bin/sh -eu
NUMSECTORS=$(($1*1024*1024*1024/512))
echo "creating ramdisk with $1 GB ($NUMSECTORS sectors)"
MYDEV=$(hdiutil attach -nomount ram://$NUMSECTORS)
echo "created $MYDEV"
diskutil eraseVolume HFS+ "ramdisk-gb" $MYDEV
echo "formatted $MYDEV"
This script creates a ramdisk with the first parameter taken as gigabytes. So runnning ./ramdisk.sh 16
will create a disk with 16 gigabytes and it will be named “ramdisk-16gb” and accessible via /Volumes/ramdisk-16gb. It will show up in finder as mounted volume. To get rid of it simply unmount it with the small icon right to the name.
ATTENTION: Everything stored on this devices will be lost when the mac is turned off or the volume is removed.