Skip to content

Instantly share code, notes, and snippets.

@dhlavaty
Last active June 4, 2024 12:06
Show Gist options
  • Save dhlavaty/aa6ea374bd0ac72f67f4108d4f83907d to your computer and use it in GitHub Desktop.
Save dhlavaty/aa6ea374bd0ac72f67f4108d4f83907d to your computer and use it in GitHub Desktop.
Create RAM disk in macOS High Sierra (10.13.3), macOS Monterey (12.6.5), macOS Sonoma (14.5)

Create RAM disk in macOS High Sierra (10.13.3), macOS Monterey (12.6.5) ARM, macOS Sonoma (14.5) ARM

Update 2023-04-24

Tested on macOS Monterey (12.6.5) with Apple M1 Pro chip (ARM architecture)

Update 2024-05-04

Tested on macOS Sonoma (14.5) with Apple M1 Pro chip (ARM architecture)

LIST DISKS

diskutil list

RAMDISK CREATE

hdiutil attach -nomount -nobrowse ram://120000      # 120000 * 512bytes = ~ 61.4 MB RAM disk

                                                    # 6000000 = ~ 3 GB RAM disk

newfs_hfs /dev/disk*                                # <- * is number generated by previous command

# Aware: '/tmp/ramdisk' path MUST exist first
mount -t hfs -v /dev/disk* /tmp/ramdisk             # <- * is number generated by previous command

RAMDISK DELETE

umount /tmp/ramdisk

hdiutil detach /dev/disk*                           # <- * is number generated by previous command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment