-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit with tested on OS X script 10.10.2 Yosemite
- Loading branch information
0 parents
commit caeb06e
Showing
5 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
install: | ||
[ ! -d /usr/local/bin/ ] && mkdir -p /usr/local/bin | ||
cp createRAMDiskandMoveCaches.sh /usr/local/bin/ | ||
cp ./OSXRamDisk.plist ~/Library/LaunchAgents/ | ||
[ -f ~/Library/LaunchAgents/OSXRamDisk.plist ] && launchctl load -w ~/Library/LaunchAgents/OSXRamDisk.plist | ||
|
||
uninstall: | ||
[ -f ~/Library/LaunchAgents/OSXRamDisk.plist ] && launchctl unload -w ~/Library/LaunchAgents/OSXRamDisk.plist | ||
[ -f /usr/local/bin/createRAMDiskandMoveCaches.sh ] && rm -f /usr/local/bin/createRAMDiskandMoveCaches.sh | ||
[ -f ~/Library/LaunchAgents/OSXRamDisk.plist ] && rm -f ~/Library/LaunchAgents/OSXRamDisk.plist | ||
[ -h ~/Library/Caches/Google/Chrome/Default ] && bash -c "rm -f ~/Library/Caches/Google/Chrome/Default; mkdir ~/Library/Caches/Google/Chrome/Default" | ||
./uninstall.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Label</key> | ||
<string>OSXRamDisk</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>/bin/bash</string> | ||
<string>/usr/local/bin/createRAMDiskandMoveCaches.sh</string> | ||
</array> | ||
<key>RunAtLoad</key> | ||
<true/> | ||
</dict> | ||
</plist> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
OS X RAM Disk | ||
================ | ||
|
||
This app will create a [RAM disk](http://en.wikipedia.org/wiki/RAM_drive) with specified size to | ||
store apps cache in RAM, which is known as SSD optimization - reducing disk IO or making browsing the web and | ||
programming using IntelliJ more enjoyable. | ||
|
||
Supported apps (you can add yours): | ||
|
||
1. IntelliJ Idea 14 | ||
|
||
1. Google Chrome | ||
|
||
1. Google Canary | ||
|
||
1. Safari | ||
|
||
1. iTunes | ||
|
||
1. todo: Android studio | ||
|
||
1. your_app_goes_here | ||
|
||
The IntelliJ Idea is really fast after this. Be warned that for large projects you will need to have larger RAM Disk. | ||
|
||
If you observing performance degradation - revise how much memory you are using and may be adding more can help. | ||
By default script will create 4Gb RAM disk. If you need to change the size - edit createRAMDiskandMoveCaches.sh | ||
|
||
Compatibility | ||
============ | ||
Works on | ||
* MAC OS X 10.10.2 Yosemite | ||
|
||
Give it a try before installing | ||
=============================== | ||
``` | ||
git clone [email protected]:zafarella/OSX-RAMDisk.git | ||
./createRAMDiskandMoveCaches.sh | ||
``` | ||
|
||
Installation | ||
============ | ||
``` | ||
git clone [email protected]:zafarella/OSX-RAMDisk.git | ||
cd OSX-RAMDisk | ||
make install | ||
``` | ||
|
||
Manual Installation | ||
------------------ | ||
``` | ||
cp OSXRamDisk.plist ~/Library/LaunchAgents | ||
cp createRAMDiskandMoveCaches.sh /usr/local/bin | ||
# note - it will close Chrome, safari idea | ||
/usr/local/bin/createRAMDiskandMoveCaches.sh | ||
``` | ||
|
||
Uninstall | ||
============ | ||
Run `make uninstall` | ||
or manually do following | ||
|
||
Close the chrome, idea or any other application you configured to use ram disk. | ||
``` | ||
rm /usr/local/bin/ChromeRamDisk.sh | ||
launchctl unload -w ~/Library/LaunchAgents/OSXRamDisk.plist | ||
rm ~/Library/LaunchAgents/com.alanthing.ChromeRamDisk.plist | ||
``` | ||
|
||
TODO | ||
=========== | ||
Add support for persisting files in HDD (rsync) and restoring on system startup - will save a lot of time | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is about to create a RAM disk in OS X and move the apps caches into it | ||
# to increase performance of those apps. | ||
# Performance gain is very significat, particularly for browsers and | ||
# especially for IDE | ||
# | ||
# Drawbacks and risks are that if RAM disk becomes full - performance will degrate | ||
# significantly. | ||
# | ||
# USE AT YOUR OWN RISK. | ||
# | ||
|
||
# The RAM amount you want to allocate for RAM disk. One of | ||
# 1024 2048 3072 4096 5120 6144 | ||
# todo: set default value to 1/4 of RAM | ||
ramfs_size_mb=4096 | ||
mount_point=/Volumes/ramdisk | ||
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512)) | ||
ramdisk_device=`hdid -nomount ram://${ramfs_size_sectors}` | ||
USERRAMDISK="$mount_point/$USER" | ||
|
||
# unmount if exists the RAM disk and mounts if doesn't | ||
mk_ram_disk() | ||
{ | ||
umount -f ${mount_point} | ||
newfs_hfs -v 'ramdisk' ${ramdisk_device} | ||
mkdir -p ${mount_point} | ||
mount -o noatime -t hfs ${ramdisk_device} ${mount_point} | ||
|
||
# Hide RAM disk, we don't really need it to be annoiyng in finder. | ||
# comment out should you need it. | ||
hide_ramdisk | ||
} | ||
|
||
# ------------------------- | ||
# Application which needs the cache to be moved to RAM | ||
# ------------------------- | ||
|
||
# Chrome Cache | ||
move_chrome_cache() | ||
{ | ||
close_app "Google Chrome" | ||
/bin/rm -rf ~/Library/Caches/Google/Chrome/* | ||
/bin/mkdir -pv $USERRAMDISK/Google/Chrome/Default | ||
/bin/ln -v -s $USERRAMDISK/Google/Chrome/Default ~/Library/Caches/Google/Chrome/Default | ||
} | ||
|
||
# Chrome Canary Cache | ||
move_chrome_chanary_cache() | ||
{ | ||
/bin/rm -rf ~/Library/Caches/Google/Chrome\ Canary/* | ||
/bin/mkdir -pv $USERRAMDISK/Google/Chrome\ Canary/Default | ||
/bin/ln -v -s $USERRAMDISK/Google/Chrome\ Canary/Default ~/Library/Caches/Google/Chrome\ Canary/Default | ||
} | ||
|
||
# Safari Cache | ||
move_safari_cache() | ||
{ | ||
/bin/rm -rf ~/Library/Caches/com.apple.Safari | ||
/bin/mkdir -pv $USERRAMDISK/Apple/Safari | ||
osascript -e 'quit app "Safari"' | ||
/bin/ln -v -s $USERRAMDISK/Apple/Safari ~/Library/Caches/com.apple.Safari | ||
} | ||
|
||
# iTunes Cache | ||
move_itunes_cache() | ||
{ | ||
/bin/rm -rf ~/Library/Caches/com.apple.iTunes | ||
/bin/mkdir -pv $USERRAMDISK/Apple/iTunes | ||
/bin/ln -v -s $USERRAMDISK/Apple/iTunes ~/Library/Caches/com.apple.iTunes | ||
} | ||
|
||
# Intellij Idea | ||
move_idea_cache() | ||
{ | ||
# todo add other versions support and CE edition | ||
# make a backup of config - will need it when uninstalling | ||
cp -f /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties.back | ||
# in case it is running not in startup - need to close the app to copy over the files. | ||
close_app "IntelliJ Idea 14" | ||
# Idea will create those dirs | ||
echo "idea.system.path=$USERRAMDISK/Idea" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties | ||
echo "idea.log.path=$USERRAMDISK/Idea/logs" >> /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties | ||
} | ||
|
||
# todo Android Studio | ||
move_android_studio_cache() | ||
{ | ||
echo "moving Android Studio cache"; | ||
echo "Not implemented" | ||
} | ||
|
||
# Closes passed as arg app | ||
close_app() | ||
{ | ||
osascript -e "quit app \"${1}\"" | ||
} | ||
|
||
# Open an application | ||
open_app() | ||
{ | ||
osascript -e "tell app \"${1}\" to activate" | ||
} | ||
|
||
# Hide RamDisk directory | ||
hide_ramdisk() | ||
{ | ||
/usr/bin/chflags hidden $mount_point | ||
} | ||
|
||
# ----------------------------------------------------------------------------------- | ||
# The entry point | ||
# ----------------------------------------------------------------------------------- | ||
# Let's close the apps we moving caches for in case they are running. | ||
close_app "IntelliJ Idea 14" | ||
close_app "Google Chrome" | ||
close_app "Safari" | ||
# and create our RAM disk | ||
mk_ram_disk | ||
# move the caches | ||
move_chrome_cache | ||
move_safari_cache | ||
move_idea_cache | ||
|
||
echo "All good - I have done my job" | ||
# | ||
# open_app "Google Chrome" | ||
# ----------------------------------------------------------------------------------- | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# close the apps | ||
|
||
osascript -e "quit app \"Google Chrome\"" | ||
osascript -e "quit app \"Chrome\ Canary\"" | ||
osascript -e "quit app \"Safari\"" | ||
osascript -e "quit app \"IntelliJ IDEA 14\"" | ||
|
||
umount -f /Volumes/ramdisk | ||
|
||
# Browsers | ||
mkdir -p ~/Library/Caches/Google/Chrome/Default | ||
mkdir -p ~/Library/Caches/Google/Chrome\ Canary/Default | ||
mkdir -p ~/Library/Caches/com.apple.Safari | ||
# Hopefully nobody edited idea properties file - deleting the items we add | ||
# todo add sed statements to remove lines "smarter" | ||
head --lines=-2 /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties /Applications/IntelliJ\ IDEA\ 14.app/Contents/bin/idea.properties |