Created
January 31, 2013 21:05
-
-
Save amcclosky/4686431 to your computer and use it in GitHub Desktop.
Bash function for creating a ram disk in OS X 10.7+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: mkramdisk 1024 ~/scratch | |
function mkramdisk() { | |
ramfs_size_mb=$1 | |
mount_point=$2 | |
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512)) | |
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}` | |
newfs_hfs -v 'ram disk' ${ramdisk_dev} | |
mkdir -p ${mount_point} | |
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point} | |
echo "remove with:" | |
echo "umount ${mount_point}" | |
echo "diskutil eject ${ramdisk_dev}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment