Create Ramdisk on macOS

Creating a 1000MB ramdisk:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$ hdiutil attach -nomount ram://$((2048 * 1000))
/dev/disk3

$ diskutil eraseVolume HFS+ RAMDisk /dev/disk3
Started erase on disk3
Unmounting disk
Erasing
Initialized /dev/rdisk3 as a 1000 MB case-insensitive HFS Plus volume
Mounting disk
Finished erase on disk3 RAMDisk

$ hdiutil detach /dev/disk3
updatedupdated2022-12-042022-12-04