To have RAM-based filesystem in OSX?
I would like do real-time monitoring, discussing one part of it here about counting quickly. No packages about it in homebrew.
How can you have RAM-based filesystem in OSX?
Solution 1:
Mac OS includes support for RAM-based filesystems via ramfs
. Everything is RAM backed so it's incredibly fast with near zero latency, but the contents are lost upon reboot.
To create one and mount it under /tmp/mymount
, create a script with the following contents and run it:
#!/bin/sh
NUMSECTORS=128000 # a sector is 512 bytes
mydev=`hdiutil attach -nomount ram://$NUMSECTORS`
newfs_hfs $mydev
mkdir /tmp/mymount
mount -t hfs $mydev /tmp/mymount
The above was adapted from the hdiutil
manual page
You can also do it in a one-liner (adapted from here):
diskutil erasevolume HFS+ 'RAM Disk' $(hdiutil attach -nomount ram://XXXXX)
Where XXXXX
is the size in 2048 byte blocks. There is also a useful script in this post on Superuser.