Create a ramdisk in mac osx

No Comments »Categories: Mac   

Create

To add a 0.5 GB ramdisk unter Mac OSX 10.6 execute in terminal window:

$ diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`

The size argument is calculated as MB * 2048. So if you want a 256 MB ram disk: 256 * 2048 = 524288

Remove

Remove the ramdisk by ejecting the drive icon.

Automate

Since after each restart the ram disk is lost, the following AppleScript application can be used as a login item to make a new one.

do shell script "
if ! test -e /Volumes/\"ramdisk\" ;  then
diskutil erasevolume HFS+ \"ramdisk\" `hdiutil attach -nomount ram://1165430`
fi
"

For details see here and here.

Tags: , ,