I wanted to use a ramdisk. SoI created one, filled it with 3GB data and unmounted it. Like this:

diskutil erasevolume HFS+ 'ramdisk' `hdiutil attach -nomount ram://8388608`
cp -pr some3GBdirectory /Volumes/ramdisk
umount /Volumes/ramdisk

That last statement removed /Volumes/ramdisk from the directory tree, but the 3GB stays allocated by a process called diskimages-helper. I need to kill it with SIGKILL to get the process removed and my memory back. What is the nice way to remove the ramdisk and get my memory completely freed?


The first command tells you which disk it is, e.g. /dev/disk2

Then diskutil eject /dev/disk2 will eject the disk and free the memory

  • 1
    The eject verb can take a volume name, e.g. diskutil eject ramdisk in your example, which still unmounts the entire disk without needing to do the lookup of the disk identifier yourself. – grg Jan 3 at 0:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .