Tuesday, 25 November 2008

Firefox cache in ramdisk (tmpfs)

I was trying to find a way to set up a ramdisk and have firefox store the cache there.

Step 1: Make a place to mount the ramdisk. In the terminal type:

sudo mkdir /media/ramdisk


Where /media/ramdisk is where you will mount the ramdisk.

Step 2: Mount the ramdisk

sudo mount -t tmpfs -o size=64M,nr_inodes=10k,mode=0777 tmpfs /media/ramdisk

We set the permisions to 777 which allows anybody and everybody to access it. Set these as you wish

Step 3 In firefox: Set the cache location to you new ramdisk

Basically type

about:config

in the URL address bar. Search for

browser.cache.disk.parent_directory

or add a new string by right clicking and choosing new. Then set the location to your ramdisk. In my case I set it to

/media/ramdisk/

Optional:

Step 4: If you wish to automount the ramdisk you need to edit your FSTAB file

gksudo gedit /etc/fstab

Add the line

tmpfs /media/ramdisk tmpfs size=64M,nr_inodes=10k,mode=777 0 0

Everything should be all set. You can check the ramdisk to see if a folder 'Cache' is created when you load firefox. Don't forget to close firefox or restart firefox before you set this up.

6 comments:

Steven said...

Isn't there a way to simply set the hard disk cache to 0 and increase the ram cache?

BobCFC said...

Thanks mate. I was just wondering about something similar when I read about tmpfs the other day... you have done all the hard work for me!

I was thinking about mounting /tmp as a ram disk. Would there be any benefit in doing that? I think archives are extracted in the current directory... and compiling using the working directory too, although I guess this could be changed.

I have 8gb ram so I am interested in any ideas

hongleong said...

I use /dev/shm so that I don't have to create a separate ramdisk. :)

Kyle Mathews said...

anyone know how to get this working in firefox 3.1? It seems the browser.cache.disk.parent_directory key is gone.

hongleong said...

Kyle, you can try creating a new key. By default, the key doesn't exist.

Kyle Mathews said...

Sweet -- didn't know I could do that. I got it working now, thanks for the help.