Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Ramdisk on macOS Mojave/Catalina?

What is the modern way the create a ramdisk on macOS Mojave or Catalina?


Specifically, how to:


- create a ramdisk for one-time use, discarded when shutting down the Mac?

- dismount & destroy the ramdisk, freeing up memory?

- create an empty ramdisk automatically when booting the Mac?

- create a ramdisk with a few specific folders created, when booting the Mac?

- Persist the content of a ramdisk when shutting down a Mac, and reload that content into a ramdisk when the Mac starts again?


Also… On Mojave/Catalina, would the newer APFS file system be more appropriate for a ramdisk than HFS+ file system?


Example of old solutions for a 1-gig drive (1 gig = 1024 * 2048 = 2097152) named `RamDisk`:


diskutil erasevolume HFS+ 'RamDisk' `hdiutil attach -nomount ram://2097152`


I have also found this snippet that seems to be using the APFS file system. But I don't understand the parts, and don't know if this is a proper way or not.


diskutil partitionDisk $(hdiutil attach -nomount ram://2097152) 1 GPTFormat APFS 'RamDisk' '100%'



Posted on Oct 3, 2019 12:31 PM

Reply
Question marked as Best reply

Posted on Oct 7, 2019 5:25 PM

Not helpful. Does not address the Question.


And incorrect.


A RamDisk will be far faster than SSD storage.


And SSD storage wears out on writes. RAM does not.

Similar questions

4 replies

Oct 14, 2019 9:57 AM in response to un.homme

The method you mention last seem to work.


Create and mount to /Volumes/ramdisk

NUMSECTORS=1000000                                                  # a sector is 512 bytes
MYRAMDISKDEVICE=`hdiutil attach -nomount ram://$NUMSECTORS`.        # eg /dev/disk4
diskutil partitionDisk $MYRAMDISKDEVICE 1 GPTFormat APFS 'ramdisk' '100%'


Unmount and free memory

diskutil eject /Volumes/ramdisk
diskutil eject $MYRAMDISKDEVICE                                     # eg /dev/disk4


Reference

https://stackoverflow.com/questions/46224103/create-apfs-ram-disk-on-macos-high-sierra

Oct 7, 2019 5:35 PM in response to un.homme

If you are going to quote the pros maybe it is worthwhile stating some cons:

  • Requires a battery when system is powered off
  • If battery fails & power fails, data is lost
  • High cost per gigabyte of memory


But regardless, hopefully someone will stop by to specifically answer your question.


In the meantime, this article may help: https://blog.macsales.com/46348-how-to-create-and-use-a-ram-disk-with-your-mac-warnings-included/

Ramdisk on macOS Mojave/Catalina?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.