Before creating large disks check from Apple documentation if memory is de-allocated after hdiutil detach
1
This guide has only CLI steps: using GUI tools might work but not covered here.
hdiutil attach -nomount ram://2097152
- creates a new “disk“ with 1 GB space
- given unit is 512 bytes
- 2048 units = 1 MB
- 2097152 units = 1 GB
- more unit examples on 1
- the command return device it created. E.g.
/dev/disk4
diskutil list
- lists available disks and volumes
- doublecheck name of the device
diskutil erasevolume HFS+ "RAMDisk" <device>
- formats device/volume
<device>
must match with the output ofhditil attach ...
command- disk is automatically mounted on
/Volumes/RAMDisk
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Unmount device
umount -f <device>
Delete RAMDISK
hdiutil detach <device>