How to Speed-up Firefox Significantly with tmpfs!

By Angsuman Chakraborty, Gaea News Network
Monday, January 5, 2009

Firefox, statistically the most popular browser in the world has a lot that is to be explored still. Though we have regularly fed you to better your firefox experience, the resource-hungriness of Firefox has always been under question. So here is a tip to speed up your firefox experience by many folds.

Its a moderately long process described by Steven Robertson as follows here. But its gonna work significantly better, I assure you.

Step 1. Reduce the size of your profile directory.

Enter about:config from your Firefox browser address bar and do the following things:

set browser.cache.disk.capacity to 20000 or thereabouts
set browser.safebrowsing.enabled to false
set browser.safebrowsing.malware.enabled to false

Step 2. Edit the fstab and prepare the backup tarball.

First, create a tarball of your profile as it currently stands.

$ cd
$ cd .mozilla/firefox
$ tar cpf packed.tar xyz123.default

xyz123.default should be replaced by your profile directory name here and below.

Now edit /etc/fstab and add a line like this:

firefox /home/steven/.mozilla/firefox/abcd1234.default tmpfs size=128M,noauto,user,exec,uid=1000,gid=100 0 0

You’ll have to adjust path components, uid and gid.

Step 3. Set up a backup and restore script.

This is an example, but is by no means the only way to do it. I’ll assume you’ve named the script ${HOME}/.pack_ffox.sh in future commands, so replace that with whatever you decide to do.

#!/bin/bash

# Change this to match your correct profile
PROFILE=”abcd1234.default”

cd “${HOME}/.mozilla/firefox”

if test -z “$(mount | grep -F “${HOME}/.mozilla/firefox/${PROFILE}” )”
then
mount “${HOME}/.mozilla/firefox/${PROFILE}”
fi

if test -f “${PROFILE}/.unpacked”
then
tar –exclude ‘.unpacked’ -cpf packed.tmp.tar “$PROFILE”
mv packed.tar packed.tar.old
mv packed.tmp.tar packed.tar
else
tar xpf packed.tar &&\
touch “${PROFILE}/.unpacked”
fi

Step 4. Switch over

With Firefox closed, you need to empty your profile directory. Either move the files currently in there to a new folder, or simply erase them (remember, a copy is in packed.tar as well). Be sure to leave the empty profile directory there for the tmpfs mount point.

$ "${HOME}/.pack_ffox.sh"

Verify that your profile directory is now mounted on tmpfs, that your files got correctly unpacked, and that the file .unpacked exists inside of your profile directory.

Now run the script again, exactly as before. This time, it will detect that your profile’s been unpacked and is ready to use, and create a new packed.tar. If it worked, you should now have the file “.mozilla/firefox/packed.old.tar” as well.

If both of those things checked out, you’re clear to start Firefox again.

I recommend adding the command to your .xinitrc or desktop-environment-specific startup settings, so that it’s ready to go when you log in. It’s also critical that you run it again before you shut down your computer, or you’ll lose all changes. One of the safest ways for users on media that doesn’t have limited write-cycles is to simply add an entry to the crontab which runs the script every five minutes. Run this command to edit the crontab:

# crontab -u USERNAME -e

which will bring up your editor. Add a line akin to this one:

*/5 * * * * $HOME/.pack_ffox.sh

Check in five minutes to make sure the mtime of packed.tar has changed, indicating that the script is working.

[To know more about this process and to get a detailed reasoning, visit gentoo]

Discussion

jwkite
May 19, 2009: 6:17 am

Thanks for the article. I am running Januty and just gave this a try. I had to tweak a few things to make it work.

In the script I changed the tar -exclude command to tar–exclude=’.unpacked’. It also took me some time to figure out that my cron was not running due to a permissions issue. Chmodding to allow execution (777 works well) resolved my issue.

Thanks again!

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :