Ramfs On Macos, Linux And Windows
This article offers step-by-step instructions on how to create and mount a RAM disk on different operating systems such as Linux, macOS, and Windows. It covers various methods including the use of imdisk and eram tools.
linux
simply use /dev/shm
the only difference is that ramfs on linux is unbounded while tmpfs is bounded
create bounded tmpfs:
1 | mount -t tmpfs -o size=2g tmpfs /mnt/tmp |
or yoy labor yourself to mount some additional ramfs:
1 | mount -t ramfs -o size=2g ramfs /mnt/tmp |
macos
/private/tmp is not ramdisk. it is just a directory cleared by startup.
ram-shell: A simple script to create a in-memory filesystem on macOS
RAM-backed filesystem mounter for Mac OS X
create and mount ramdisk:
1 |
|
to replace /private/tmp with ramfs and registered as launchd service
calculate sector numbers by hand:
disk_size(MiB)* 1024KiB/MiB * 1024B/KiB / 512B/sector = #sectors
1 | hdiutil attach -nomount ram://#sectors |
windows
a curated ramdisk software list
use third-party ramdisk tool like imdisk, eram with kernel driver installed, secure boot disabled (no uefi maybe?)