Created
April 14, 2020 19:32
-
-
Save nolochemical/faf2bd404721ee2ddb6e351f7163b1d0 to your computer and use it in GitHub Desktop.
RamdiskScript ( Mac )
This file contains 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
RD_SIZE=600 #MB | |
print_usage() { | |
echo "\n *With great power comes great responsibility* \n\nUsage: $0 \n -c create a ramdisk with -n <diskname>\n -d delete a disk with -n <diskname>\n Manually *Caution*: \n $ hdiutils detach /dev/<diskname> \n\nAll Mounted Disks\n=================\n`mount | sort`\n=================\n " 1>&2; exit 1; | |
} | |
while getopts 'n:cdv' flag; do | |
case "${flag}" in | |
n) if [ -z "$flag" ]; then | |
echo Please enter a disk name | |
exit | |
else NAME=${OPTARG} | |
fi | |
;; | |
c) diskutil erasevolume HFS+ ramdisk-$NAME `hdiutil attach -nomount ram://$((RD_SIZE*2048))` | |
cd /Volumes/ramdisk-$NAME | |
exit | |
;; | |
d) hdiutil detach /Volumes/ramdisk-$NAME | |
exit | |
;; | |
*) print_usage | |
exit 1 ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./ramdisk.sh: illegal option -- l
With great power comes great responsibility
Usage: ./ramdisk.sh
-c create a ramdisk with -n
-d delete a disk with -n
Manually Caution:
$ hdiutils detach /dev/