Created
October 22, 2012 11:35
-
-
Save hidsh/3931129 to your computer and use it in GitHub Desktop.
ram disk for mac
This file contains hidden or 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 | |
# | |
# mkramdisk.sh : prepare ramdisk for mac | |
# | |
# install: | |
# 1. modify variables (caches, mb) as your like, in this script. | |
# | |
# 2. register to startup: | |
# 1. open "Ligon" | |
# 2. New to "Users Daemons" | |
# 3. Label: "mkramdisk" | |
# 4. ProgramArguments:"/PATH/TO/mkramdisk.sh" | |
# 5. RunAtLoad: check | |
# 6. Save & Load: push | |
# | |
# list for app caches from /Users/user/Library/Caches | |
caches=' | |
com.apple.Safari | |
QCCompositionRepository-com.apple.iTunes.cache | |
com.apple.iTunes | |
com.apple.appstore | |
' | |
mb=2048 # size (MB) | |
mountpoint=/Volumes/.RamDisk | |
dir=cache | |
# prepare ramdisk | |
sect=`expr $mb \* 1024 \* 1024 \/ 512` | |
mydev=`hdid -nomount ram://$sect` | |
mask=`umask` | |
umask 000 | |
/sbin/newfs_hfs $mydev | |
mkdir $mountpoint | |
/sbin/mount -t hfs $mydev $mountpoint | |
#/usr/sbin/diskutil renameVolume $mydev '.RamDisk' # <-- FIXME: why doesn't work | |
# dig directory | |
mkdir -p $mountpoint/$dir; cd $mountpoint/$dir | |
for d in $caches; do | |
mkdir $d | |
done | |
umask $mask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment