Skip to content

Instantly share code, notes, and snippets.

@xanoni
Last active August 7, 2021 04:01
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 xanoni/7330906105c591537255619376aa9421 to your computer and use it in GitHub Desktop.
Save xanoni/7330906105c591537255619376aa9421 to your computer and use it in GitHub Desktop.
MacOS: create/destroy a ramdisk
#! /usr/bin/env -S bash -ex
if [ -z "${1}" ]; then
echo -en "\nPlease provide number of Gs (as integer or float)!\n\n" && exit 1
fi
disk_size=$(bc -l <<< "2048*1024*${1}")
diskutil erasevolume HFS+ "ram" $(hdiutil attach -nomount ram://${disk_size})
#! /usr/bin/env -S bash -ex
hdiutil eject /Volumes/ram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment