Tag Archives: shell

Creating a RAM disk on Mac OS X

Here is a pair of shell functions to create and destroy a RAM disk on Mac OS X. # Creates a RAM disk device, formats it as HFS+, then mounts it. # parameters: size in megabytes create_ram_disk() { local RAMDISK_SIZE_MB=$1 local RAMDISK_SECTORS=$((2048 * $RAMDISK_SIZE_MB)) RAMDISK_DEVICE=`hdiutil attach -nomount ram://$RAMDISK_SECTORS` RAMDISK_PATH=`mktemp -d /tmp/ramdisk.XXXXXX` newfs_hfs $RAMDISK_DEVICE # format as