Skip to content

Instantly share code, notes, and snippets.

@bitboxx
Forked from jnschulze/osx_ramdisk.sh
Last active August 23, 2018 09:08
Show Gist options
  • Save bitboxx/5f10b648755781c21dcd4b23f35635ab to your computer and use it in GitHub Desktop.
Save bitboxx/5f10b648755781c21dcd4b23f35635ab to your computer and use it in GitHub Desktop.
Create Ramdisk on Mac
#!/bin/bash
MOUNT_PATH=~/tmp/RamDiskCache
mkdir -p ${MOUNT_PATH}
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://8388608`
echo "Ramdisk device: ${DISK}"
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" ${DISK}
sudo /usr/sbin/diskutil mount -mountPoint ${MOUNT_PATH} ${DISK}
/usr/bin/chflags hidden ${MOUNT_PATH} #Hide RamDisk directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment