Created
April 26, 2024 04:43
-
-
Save kana/8f2bd18badc9321d788c16401d6f1f26 to your computer and use it in GitHub Desktop.
Create a RAM disk on macOS.
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
#!/bin/bash | |
set -euxo pipefail | |
MB=100 | |
NUMSECTORS=$((MB * 1024 * 1024 / 512)) # A sector is 512 bytes. | |
# "hdiutil attach" outputs extra spaces/tabs. They must be removed. | |
MYDEV="$(hdiutil attach -nomount "ram://$NUMSECTORS" | sed 's/[ \t]*$//')" | |
diskutil eraseVolume APFS "ramdisk-${MB}mb" "$MYDEV" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment