Ubuntu: Run chrome with cache in a ramdisk

This script will create a ramdisk, mount it and run chrome using it as it's cache location. Depnding on how much memory you have in your system, you can adjust the size of the ramdisk by modifying the CACHE_MB variable (number of MB you want to allocate). You can modify the icon that launches chrome to use this script, just place it somewhere in you home directory.
While not secure, I recommend adding /bin/mount and /bin/unmount to your sudoers so that you don't have to enter a password every time you run it.

#Anthony Camilo 09/02/2011
# config

#do not modify below
CACHE_SIZE=$(($CACHE_MB * 1024 - 1))
if [ ! -d  $CACHE_DIR ]; then
    mkdir -p $CACHE_DIR
    find $CACHE_DIR -mmin +480 -delete
    mkdir -p $CACHE_DIR
sudo mount -t tmpfs -o size=$CACHE_MB'M' tmpfs $CACHE_DIR
/opt/google/chrome/google-chrome $1 --disk-cache-dir="$CACHE_DIR" --disk-cache-size=$CACHE_SIZE
sleep 10
sudo umount -fl $CACHE_DIR

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.