Create APFS RAM disk on macOS High Sierra

∥☆過路亽.° 提交于 2019-12-02 16:21:37

@Glyph provided the best answer in a comment to the accepted answer, but it deserves its own answer:

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

I've updated Glyph's answer to simplify the volume name a little.

Found a solution:

hdid -nomount ram://<blocksize>
diskutil erasedisk <format> <diskname> <output path of previous hdid command>

where <format> is taken from diskutil listFilesystems from the "Personality" column. Yes, it seems weird to me too that you may have to quote this parameter, e.g. when specifying case-sensitive variants, but oh well...

<blocksize> is 2048 * desired size in megabytes

The last command formats the RAM disk and mounts it to /Volumes/<diskname>

It seems to be the case that when now entering diskutil list that you will see two new disks, the one hdid created, and a synthesized one.

To destroy the RAM disk again, call diskutil eject <output path of previous hdid command>, e.g. diskutil eject /dev/disk2

This will do all the work for you, unmounting the /Volumes/<diskname> path and destroy the two disks, releasing your memory.

Keep in mind that the minimum/maximum values for <blocksize> depend on the chosen <format>. Also, <diskname> cannot always be chosen arbitrarily. Exemplary, FAT32 requires it to consist of upper-case letters!

Cheers!

sw.smayer97

Also, info to delete/destroy the RAM disk needs to be corrected. ramdisk will be created at path /Volumes/'ramdisk', so the command is:

diskutil eject /Volumes/'ramdisk'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!