Skip to content

Instantly share code, notes, and snippets.

@Tolsi
Last active June 7, 2016 16:59
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 Tolsi/c1cf0d8958d113740dcff78b387e958c to your computer and use it in GitHub Desktop.
Save Tolsi/c1cf0d8958d113740dcff78b387e958c to your computer and use it in GitHub Desktop.
Bash functions for create/mount and umount RAM partitions for Mac OS X 10.11
# pass size in mb and optional name
function ram_disk_mb() {
name=${2:-disk}
diskutil erasevolume HFS+ "ram_$name" $(hdiutil attach -nomount ram://$(($1*2048)))
}
# pass size in gb and optional name
function ram_disk_gb() {
ram_disk_mb $(($1*1024))
}
# unmount partition with given name or all partitions with the default name
function umount_ram_disks() {
umount /Volumes/ram_*
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment