Blazing Fast Firefox using OSX RamDisk


Firefox does a lot of IO to the disk even thou you have lots of spare Ram, due to Sqlite, Bookmarks, History and Cache.

To make Firefox faster is to store the whole profile folder into a Ram Disk.
RamDisk in Linux are called TmpFS. You can also use shared memory folder /dev/shm if you have it in your fstab.

This post in the gentoo forums explains how to do it in Gentoo linux.

I made a similar script to make it work in OSX Leopard.

The Script have 2 parts, Start.sh and Stop.sh
Here are the Scripts:

Start.sh

#!/bin/bash
# Run this script to enable the Ramdisk for Firefox profiles
VolumeName="Mozilla"
 
# Size in MB, make sure is not too low or not too high
SizeInMB=220
 
NumSectors=$((2*1024*SizeInMB))
 
DeviceName=`hdid -nomount ram://$NumSectors`
 
echo $DeviceName
 
diskutil eraseVolume HFS+ RAMDisk $DeviceName
 
# move the current profiles folder
mv Profiles Profiles_ &&
 
# make a symlink to the ramdisk
ln -s /Volumes/RAMDisk ./Profiles &&
 
# then copy it to the ramdisk
/bin/cp -r Profiles_/* Profiles

Stop.sh

#!/bin/bash
cd ~/Library/Cache/Firefox/
 
# clean the cache
rm -rf  Profiles/*/Cache/* &&
 
# will save your modifications back to the DISK
/usr/bin/rsync -av --delete ./Profiles/ ./Profiles_/ &&
 
# sometimes during unmount it will say disk is in use.
# make sure you close firefox before.
umount /Volumes/RAMDisk &&
rm -rf Profiles &&
mv Profiles_ Profiles

You can also use ‘tar’ instead of ‘rsync’. I just love rsync more.

* Warning: The ramdisk contents will be erased after you umount the ramdisk.

Have fun.

Gentoo Linux ROCKS

Update:

To speed up firefox even moreĀ  run these commands:

cd ~/Library/Caches/Firefox/Profiles
 
for i in */*.sqlite; do sqlite3 $i VACUUM;done;
 
cd ~/Library/Application\ Support/Firefox/Profiles
 
for i in */*.sqlite; do sqlite3 $i VACUUM;done;
VN:F [1.8.3_1051]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.3_1051]
Rating: 0 (from 0 votes)

, , ,

  1. #1 by Kevin on December 24, 2008 - 11:06 am

    Hi! I can’t seem to get this to work on my system. I created the start.sh file and placed it inside the folder where it is supposed to run. But nothing is being copied.

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  2. #2 by admin on December 24, 2008 - 11:17 am

    U may have to modify a little the script.
    do you have macports installed?
    what does it say when you run?

    did make the script executable?
    $ chmod 755 start.sh

    I changed the script above a little.

    UA:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UA:A [1.8.3_1051]
    Rating: 0 (from 0 votes)
  3. #3 by gigio on May 23, 2009 - 12:50 pm

    Hi! could you please post the script using TAR instead of rsync ?
    I’m not a bash expert and wasn’t able to use rsync nor to install it

    Thank you very much in advance!

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  4. #4 by RixiM MixiR on August 21, 2009 - 12:41 pm

    wouldn’t it make sense to use a “lighter” fs than HFS+ in this case?

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  5. #5 by admin on September 24, 2009 - 5:19 am

    i like hfs+ cause it has journaling and is native to OSX…
    I’m no way gonna use fat32. :)

    UA:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UA:A [1.8.3_1051]
    Rating: 0 (from 0 votes)
(will not be published)