Ubuntu – Move Google Chrome cache from SSD to RAM

Running an SSD for the main boot partition is quite convenient for any OS, including Ubuntu. However having Google Chrome, or any browser, store its cache on the SSD is not the ideal scenario.
Under Ubuntu Natty 11.04 moving Google Chrome’s cache to RAM is fairly simple and only takes a few commands. The advantages to storing the web browser cache in RAM are: quicker read/write than hard drives, no wear and tear on hard drives and it will be erased on reboot. The disadvantages are: will be erased on reboot and will consume RAM which can be limited on some systems.

1) Decide where to move the Chrome cache location to. I’ve picked the following location: /tmp/chrome.
This directory, /tmp/chrome will need to be created on boot and properly setup.
On Ubuntu 11.04 and probably older versions, this can be simply done in the /etc/rc.local file as follows:
sudo gedit /etc/rc.local
Add the following lines:
mkdir /tmp/chrome
mount -t tmpfs -o size=1024M,mode=0744 tmpfs /tmp/chrome/
chmod 777 /tmp/chrome/ -R

There are two ways to accomplish the next and last step. One is to create a symlink between the default google cache directory and the new temporary cache directory in RAM. The second is to add a switch to the google chrome command line telling each instance of the application to use our newly created cache directory in RAM.
1) rm -rf ~/.cache/google-chrome
ln -s /tmp/chrome/ ~/.cache/google-chrome
OR
2) Change the default here: sudo gedit /usr/local/share/applications/google-chrome.desktop
Replace the line:
#Exec=/opt/google/chrome/google-chrome %U
with
Exec=/opt/google/chrome/google-chrome –disk-cache-dir=”/tmp/chrome/”

The only adjustment some might wish to make will be the size of the tmpfs partition created in RAM above. I set the size to 1024MB as I don’t ever want to have to worry about or adjust it. My system is currently running on 24GB of RAM so the above size should not be an issue with the current system limitation.

Used the following main sources:
Firefox & Chrome Cache on RAM Drive -Fedora / Ubuntu
How To Change Google Chrome’s Cache Location And Size

Leave A Reply

Comments

No comments yet, be the first to add one!