Last active
August 7, 2021 04:01
-
-
Save xanoni/7330906105c591537255619376aa9421 to your computer and use it in GitHub Desktop.
MacOS: create/destroy a ramdisk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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