March 19, 2016
You can create and mount a ram based disk as follows:
- Create a disk:
$ hdiutil attach -nomount ram://$((2 * 1024 * SIZE_IN_MB))
hdiutil will return the name of the ramdisk.
- Format and mount the disk diskutil eraseVolume HFS+ RAMDisk NAME_OF_DISK Creating a 100MB ramdisk:
$ hdiutil attach -nomount ram://$((2 * 1024 * 100)) /dev/disk3
- Started erase on disk3 Unmounting disk Erasing Initialized /dev/rdisk3 as a 100 MB case-insensitive HFS Plus volume Mounting disk Finished erase on disk3 RAMDisk:
$ diskutil eraseVolume HFS+ RAMDisk /dev/disk3
Source:
linux – Does OS X have an equivalent to /dev/shm? – Stack Overflow