Thursday, January 3, 2013

Mounting Chrome cache in memory

As seen in my Ubuntu 12.04 installation post, I use a script to keep the Chrome cache in RAM.

I found this tip somewhere (don't recall where) and have been using it for some time now.

Mounting Chrome cache in memory will give you the speed of RAM vs. the speed of an hard drive.

Do you have any more tips like this?

Script

  • Create the script:
$ vi ~/bin/chrome_tmp_cache.sh
  • Add the following to the script:
#!/bin/bash
if test -d /tmp/chrome; then
  exit 0
else
  rm -r ~/.cache/google-chrome
  mkdir /tmp/chrome
  ln -s /tmp/chrome ~/.cache/google-chrome
fi
  • Change the script permissions:
$ chmod +x bin/chrome_tmp_cache.sh
  • Add the script to the Startup Applications:
Name: Chrome Cache
Command: /home/<user>/bin/chrome_tmp_cache.sh
Comment: Move Chrome cache to /tmp

Mounting /tmp in RAM

For this script to work, /tmp must be mounted in memory. Just add the following to your /etc/fstab file:
  • Open /etc/fstab as root
$ gksu gedit /etc/fstab
  • Add the following line
tmpfs /tmp tmpfs nodev,nosuid,noatime,mode=1777 0 0