Less Software
RAM Folder RAM Folder macOS RAM Disks Guide

macOS RAM Disks Guide

A RAM disk is one of the oldest performance tricks on the Mac, and still one of the most effective. This guide explains what a macOS RAM disk actually is, how the classic disk-image approach (diskutil / hdiutil) compares to the modern tmpfs one, how to create one, and how to keep your data safe when the disk lives in volatile memory.

What is a RAM disk on macOS?

A RAM disk (also written RAMDisk) is a filesystem whose contents are stored entirely in your Mac’s memory instead of on the SSD. macOS hands it a normal path — sometimes even a normal volume name — so it looks like any other disk, except that reading and writing to it never touches storage hardware.

The practical consequences are simple. Because there is no storage-controller latency, IO-bound work runs dramatically faster (often 2–3× that of a fast SSD drive) and produces no SSD wear. The trade-off is that RAM is volatile: when the machine loses power, the RAM disk’s contents are gone.

How to create a RAM disk on macOS

There are five common ways to get a RAM disk on a modern Mac: three variations on diskutil disk images, the raw tmpfs filesystem, and RAM Folder, which builds on tmpfs. The examples below all create a 4 GB volume formatted as APFS — see filesystem values for the alternatives.

With diskutil: a ram:// disk with no backing image

diskutil image attach (previously hdiutil attach) creates a block device that lives only in memory. It is sized either in 512-byte sectors (ram://8388608 is 4 GB) or with a unit suffix (ram://4GB). The device comes up blank, so format it before use, then eject it when you are done:

This is fast to set up but entirely manual: every reboot you repeat it, and anything you forget to copy out is lost.

With diskutil: backed by a .dmg image

diskutil image create blank writes a disk image file that already contains a formatted volume. Attaching it mounts that volume; ejecting it leaves the file — and everything you wrote — on disk, ready to be attached again.
Note: A plain .dmg is a raw image. With APFS(X/I), its size will dynamically grow and shrink depending on the volume contents. For all other filesystem values though, the image is pre-allocated, so the file takes its full size on disk from the start:

With diskutil: backed by a .sparseimage

A sparse image starts small and grows as data is written, so it does not claim its full size on disk up front (it does not shrink back on its own, though: reclaiming space takes hdiutil compact). diskutil image create cannot produce the single-file .sparseimage format — it only offers .sparsebundle and .asif — so the image is created with the deprecated hdiutil create, which still works, and attached with diskutil:

For a format diskutil creates natively, use a .sparsebundle path instead (diskutil image create blank --fs APFS --size 4GB ~/ramdisk.sparsebundle): a folder of small band files that grows the same way.

Filesystem values for diskutil

diskutil eraseVolume takes a filesystem personality as its first argument (case does not matter, and the aliases work too). Run diskutil listFilesystems to see the list on your Mac:

Value (alias) Filesystem When to use it
APFSI APFS, case-insensitive The modern macOS default; matches your startup disk. Used in every example here
APFSX APFS, case-sensitive Tools that expect Linux-like case sensitivity; some Mac apps break on it
JHFS+ Mac OS Extended, journaled The pre-APFS default; the journal adds writes a RAM disk does not need
JHFSX Mac OS Extended, case-sensitive, journaled Case-sensitive HFS+ with a journal
HFS+ Mac OS Extended, no journal The traditional RAM disk choice before APFS: light, with no journaling overhead

diskutil image create blank --fs only accepts APFS.
Use hdiutil create -fs or reformat with diskutil eraseVolume for the others.

With mount_tmpfs (command line)

mount_tmpfs mounts a tmpfs volume over any existing directory. There is no device to create or format, and -s sets the size ceiling rather than a reservation. It needs administrator rights, and the mounted volume belongs to root until you hand it over:

Mounting over a folder hides what was in it until you unmount, and nothing is copied in or out: the tmpfs volume always starts empty and is lost at unmount or reboot.

Plain tmpfs behavior: the folder's files are hidden while the volume is mounted, and everything written to RAM is lost at unmount

With RAM Folder (GUI + CLI)

RAM Folder uses the same tmpfs backend, but imports the contents of a folder you already use into the RAM disk, at the very same path, so there is nothing to migrate or reconfigure. It also saves the disk’s contents back to storage and can remount at login:

Where plain tmpfs hides the folder’s files and discards everything written to RAM, RAM Folder copies the folder’s files into RAM right after mounting, and copies the RAM contents back into the folder at unmount, so the folder always holds your latest work:

RAM Folder with Sync RAM folder on: the folder's files are imported at mount and saved back at unmount

For throwaway data such as build caches, turn Sync RAM folder off: the folder’s files are still imported at every mount, but changes made in RAM are discarded at unmount and the original folder reappears unchanged.

RAM Folder with Sync RAM folder off: the folder's files are imported at mount, and RAM changes are discarded at unmount

RAM disk methods compared

Method Filesystem Keeps data after unmount Memory used Disk space used Seq. perf (*) Rand. perf (*)
diskutil,
ram:// only
APFS No Full volume size None r: 37.6 GB/s
w: 15.7 GB/s
r: 1.1 GB/s
w: 91 MB/s
diskutil +
.dmg
APFS Yes, in the image file Full volume size Grows and shrinks with contents r: 25.3 GB/s
w: 17.4 GB/s
r: 565 MB/s
w: 46 MB/s
diskutil +
.dmg
HFS+ Yes, in the image file Full volume size Full volume size r: 25.1 GB/s
w: 17.4 GB/s
r: 631 MB/s
w: 12 MB/s
diskutil +
.sparseimage
APFS Yes, in the image file Full volume size Grows with contents; shrinks when calling hdiutil compact r: 2.1 GB/s
w: 874 MB/s
r: 33 MB/s
w: 8 MB/s
mount_tmpfs tmpfs No Only what the files use (size is a ceiling) None r: 49.3 GB/s
w: 43.0 GB/s
r: 2.3 GB/s
w: 589 MB/s
RAM Folder tmpfs Yes, saved to disk (opt. periodic snapshots) Only what the files use (size is a ceiling) Only the saved copy of your files idem idem

(*) r: read, w: write. Performance benchmarks were made with fio on 4 GB volumes, on a Mac Studio M1 Max with 64 GB of RAM:
1 GB test file, direct IO, 10 s per test; seq uses 1 MB blocks at queue depth 8, rand uses 4 KB blocks at queue depth 32.

Sizing a RAM disk: a ceiling, not a reservation

On a tmpfs disk the size you set is a ceiling, not a reservation. An 8 GB RAM disk holding 300 MB of files uses roughly 300 MB of RAM: memory is consumed as files are written and released as they are removed. It is safe to size a scratch disk generously “just in case”, as long as you do not actually fill it — a disk that does fill up really does consume that much memory.

Does a RAM disk survive a reboot?

No — RAM is cleared on shutdown, restart and power loss, so a RAM-backed disk is empty or gone after a reboot. (The one exception is the disk-image RAM disk described above, which persists because its image is a file on disk — but that is exactly the approach that pays for persistence in performance and memory.) To keep your work, it has to be saved to real storage before the machine goes down.

RAM Folder performs that save at eject, at quit, and (optionally) on periodic snapshots, then remounts and refills the disk at login. A hard crash or power cut can still lose anything written since the last save, which is why the periodic snapshot exists — see the Data Safety notes for the details.

What a macOS RAM disk is good for

macOS RAM disk apps compared

Tool Backend Interface Saves to disk Mount at launch
diskutil Disk image Command line Yes Manual
TmpDisk Disk image & tmpfs Open-source GUI No (temporary by design) Not built in
iRamDisk Disk image GUI Varies Varies
RAMDisk Manager Disk image GUI Varies Yes
RAM Folder tmpfs Native GUI + CLI Yes, automatic Yes (can also launch at login)

Third-party tools change over time — check each product’s own site for current features and pricing.

A RAM disk that behaves like an ordinary folder

RAM Folder makes a macOS RAM disk so well-integrated it behaves like any other folder: same path, same name, no migration — and it saves itself back to disk or cloud storage. Two to three times faster than the fastest Mac drive, with a one-time €11.99 license and a 14-day free trial.

See RAM Folder →