3 # +----------------------------------------------------------------------+
5 # | Set up Mac OS X to store temporary files in RAM rather than on disk.|
6 # | Updated for Yosemite, 16 GB of RAM |
8 # | By James Newell <jrnewell@github> |
10 # | Originally by Ricardo Gameiro <http://blogs.nullvision.com/?p=357> |
11 # | Changes by Daniel Jenkins |
12 # | <http://blogs.nullvision.com/?p=357#comment-1140> |
13 # | Additional changes by Benjamin Chu <http://intechnicolor.net> |
14 # +----------------------------------------------------------------------+
16 # if you want a different location for startup script, change this variable
17 SCRIPT_DIR
=/usr
/local
/sbin
20 SCRIPT_DIR
=/opt
/Galaxy
23 if [ ! -d "$SCRIPT_DIR" ]; then
24 echo "$SCRIPT_DIR does not exist. Either create the directory or change SCRIPT_DIR in this script..."
29 cat << "EOF" |
tee "$SCRIPT" > /dev
/null
32 # Create a RAM disk with same perms as mount point
35 local ramdisk_size
=$
(($2*1024*1024/512))
38 echo "Creating RamFS for $mount_pt"
39 local ramdisk_dev
="$(hdiutil attach -drivekey system-image=yes -nomount -noautoopen ram://${ramdisk_size} | sed -e 's/[[:space:]]*$//')"
41 # seems to help with preventing issue where some disks did not mount
47 # Create HFS on the RAM volume.
48 sudo newfs_hfs
-v "$3" $ramdisk_dev
50 # Store permissions from old mount point.
51 eval `/usr/bin/stat -s $mount_pt`
53 # Mount the RAM disk to the target mount point.
54 sudo mount
-t hfs
-o noatime
-o union
-o nobrowse
"$ramdisk_dev" "$mount_pt"
56 # Restore permissions like they were on old volume.
57 sudo chown
$st_uid:$st_gid "$mount_pt"
58 sudo
chmod $st_mode "$mount_pt"
62 # 512 MB for temp directory
63 #RAMDisk "/private/tmp" 512 "RAM Temp"
64 RAMDisk
"/private/tmp" 768 "RAM_Temp"
66 # 128 MB for run directory
67 #RAMDisk "/var/run" 128 "RAM Run"
70 sudo
chmod u
+x
,g
+x
,o
+x
"$SCRIPT"
72 cd /Library
/LaunchDaemons
73 cat << EOF | sudo tee me.Galaxy.ramdisk.plist > /dev/null
74 <?xml version="1.0" encoding="UTF-8"?>
75 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
79 <string>RAM Temp Disks</string>
81 <key>ProgramArguments</key>
83 <string>${SCRIPT_DIR}/${SCRIPT}</string>