Howto:Firefox profile in RAM for increased speed /stability

Discussion in 'Linux' started by Bossieman, Apr 11, 2009.

  1. Bossieman

    Bossieman

    Joined:
    Aug 15, 2008
    Messages:
    20
    Likes Received:
    0
    NOTE: This howto has been tested in Ubuntu 9.04 Jaunty Jackalope and Firefox version 3.0.8. but should work for any Ubuntuversion and most other distros.

    This howto is based on the discussion from a forumthread http://forums.gentoo.org/viewtopic-t-717117-highlight-firefox.html over at the Gentoo Forums and this guide http://www.verot.net/firefox_tmpfs.htm" from verot.net
    Credits goes to stevenrobertson at the Gentoo Forums for the original post

    One of the problems that will disappear after completing this guide is based on the following

    http://www.verot.net/firefox_tmpfs.htm

    The result of this guide will give you

    * Much less disk activity
    * Immediate search results when you search in about:config and the AwsomeBar.
    * None/very few Firefox hangups and freezes.
    * Faster rendering of webpages.
    * Firefox cache almost impossible to obtain after the computer shut down.

    This guide makes huge difference for all AspireOne-users. This because of the slow SSD-harddrive, the difference before and after will be huge.

    You don't need a lot of RAM to benefit from this guide. Your Firefox profile don't need to be especially large if you reduce the amount of cache in your Firefoxprofile, I guess approximately 64 MB additional RAM is atleast required to benefit from this guide.

    To see how much difference this guide really do, I recommend that you start by doing the following easy tests.
    Open up a new tab and see how fast the new tab appears. Start typing some webpage you visit frequently into the address bar (AwsomeBar). Try to get an idea of how quickly the AwsomeBar works. Try also to enter about:config and get an idea of how quickly the results come up in your searches. After you completed this guide, do the same tests to see some of the differences in speed you will get from this howto.

    So lets start this guide;

    Type about:config into Firefox AwsomeBar and press Enter. Read the message that comes up and then click it to enter about:config

    Type browser.cache.disk.enable into the filter field and verify that the value is True. If set to False doubleclick the result to change to True.
    Type browser.cache.disk.capacity into the filter field and doubleclick the result to change the value. If you want your Firefoxprofile to use only a small amount of RAM change the value to 20000 or below. If you have plenty of free RAM enter a big value, like 128000 or more. I have 4 GB of RAM so I use the value 131072 [128 Mb]. AspireOne users with 512 MB of RAM I suggest the value 16384 [16 Mb]
    This value is just one part of your Firefoxprofile so the total amount of RAM your Firefoxprofile will use will be about 50 Mb more. Remember the value you enter, we need it later on.

    The original author suggested to change the values for

    browser.safebrowsing.enabled to False

    browser.safebrowsing.malware.enabled to False

    I recommend you also to follow some guide on the internet that suggests good modifications for about:config for great improvement in speed.

    After this is done, go to your .mozilla/firefox folder and create a folder there and name it profile. The folder .mozilla is hidden so you have to press Ctrl + h in your homedirectory to see hidden files and folders.
    Copy all of the content from the folder xxxxxx.default(xxxxxxx represents random letters and numbers) into the folder profile. If you are going to use a small amount of RAM for your Firefoxprofile then empty the folder Cache inside your xxxxxx.default folder before copying the content.
    I recommend you to make another copy of xxxxx.default and place it somewhere safe just in case something happens.
    The folder profile will be used for saving the changes to your Firefoxprofile from RAM so the changes wont get lost after computer shut downs or a after a reboot. More on that later.

    Create now in a place you remember an empty file (Right-click on eg the desktop and select Create Document -> Empty file). Give the file the name tmpfs_firefox.sh
    Doubleclick the file and paste the following text to it.

    Code:
    #!/bin/bash
    
    # Change this to match your correct profile
    PROFILE="xxxxxxxx.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
        rsync -av --delete --exclude .unpacked ./"$PROFILE"/ ./profile/
    else
        rsync -av ./profile/ ./"$PROFILE"/
        touch "${PROFILE}/.unpacked"
    fi
    
    exit
    Important: Modify the line PROFILE="xxxxxxxx.default" so it represent the exact name of your xxxxxxxx.default directory.
    My folder is named rcw72e7n.default so my line will look like this

    PROFILE="rcw72e7n.default"

    When your are absolutely sure your file is correct save the file and exit your editor,
    Rightclick the file tmpfs_firefox.sh and select Properties. Go to the tab Permissions and change the permissions so Run is marked to the right of owner. Close the window when you are finished.

    Now press Alt + F2 and enter

    gksudo gedit /etc/fstab

    and hit Run.

    I the textdocument that appears put this line to the end of the file

    Code:
    firefox /home/USERNAME/.mozilla/firefox/xxxxxxx.default tmpfs size=AMOUNT_OF_RAM_TO_USE,noauto,user,exec,uid=1000,gid=1000 0 0
    Important: Change USERNAME to your username on the computer. Change xxxxxxx.default so it represents the name of your xxxxxxx.default folder. Change AMOUNT_OF_RAM_TO_USE to a value about 70Mb larger than your browser.cache.disk.enable value. In other guides, where people have made similar modifications, it has been recommended 128M if browser.cache.disk.capacity is set to 20000. For AspireOne users with 512 Mb of RAM I suggest the value 96M
    I used the value 131072 [128 Mb] for my browser.cache.disk.capacity so the line for me to put into /etc/fstab would look something similar like this

    Code:
    firefox /home/leif/.mozilla/firefox/rcw72e7n.default tmpfs size=200M,noauto,user,exec,uid=1000,gid=1000 0 0
    When you are absolutely sure your line is correct save the file and exit the editor.

    We must now empty the content of your .mozilla/firefox/xxxxxx.default directory. To do this we have to shut down Firefox completely to avoid Firefox from re-create the profile. You can copy the relevant part of the guide to a text file or use another browser for the next part, but you have to exit Firefox before erasing the content. Before you empty the folder, doublecheck that you have a copy of the content of .mozilla/firefox/xxxxxx.default in the directory .mozilla/firefox/profile and I recommend an extra copy somewhere safe.

    When Firefox is closed erase the content of .mozilla/firefox/xxxxxx.default. Look down to the left corner in the Nautilus window and remember the amount of free space you have in your .mozilla/firefox/xxxxxx.default directory.

    When this is done locate the file tmpfs_firefox.sh we created earlier and doubleclick it. A window will appear. Chose Run in terminal.
    You will now see a terminal window open and close very quickly. This is normal and due to the fact that the whole process went very quickly. The script mounted your Firefox profile into your computer's RAM. Double-click again on the file tmpfs_firefox.sh and select once more Run in terminal. The same thing happens as before but with the difference that the script synchronized the contents of the folder with your profile folder xxxxxx.default.

    Now enter the folder xxxxxx.default. You should now see that the erased files are back.
    Look down to the left corner in the Nautilus window when you are in the folder xxxxxx.default and you should see that the value of free discspace now have changed and now shows the amount of free space in your computers RAM for the xxxxxx.default folder. If you see no difference try hitting refresh in nautilus.

    If the content of xxxxxx.default is back and the amount of free discspace inside the xxxxxx.default directory have changed to a size around the same size you entered into your /etc/fstab file you can safetely start up Firefox.
    After Firefox have started, repeat the same tests as we did at the beginning of the guide to confirm the difference in speed. Open up a new tab, this will be noticeably faster than before. Enter about:config into the awsomebar and press enter. Now the box to be careful should appear immediately. Press, I promise, I will be careful and you'll immediately arrive to about:config
    Perform a search in the filter box and you will see that the results will appear with no delays at all. Test also in the awsomebar to start typing a webpage you usually visit and note that the results from the search appears immediately. Another thing you will notice is that the your computer harddrive is working much less now than before. When Firefox have build up some cache, you'll also notice a difference in renderingspeed of the pages you visit.

    Now we have to make sure your computer synchronize the RAM to the hard disk so the changes in your Firefoxprofile is saved after you restart or shut down the the computer. To do this we need to install gnome-schedule. Use Synaptic for this or enter sudo apt-get install gnome-schedule in a terminal to install it. When the installation is complete, start the application, Applications -> System Tools -> Scheduled tasks. If you cant find the program enter gnome-schedule into the box that appears after you press Alt + F2 and then hit Run.

    When the program have started, click New, which is at the top left of the program. A window appears. Select the top option, a task that is running recurring. A new box appears. Enter the following

    Description: Whatever you want

    Command: $HOME/.tmpfs_firefox.sh

    Mark the box that says Advanced and enter the following

    Minute: */5

    Enter a * into the four remaining fields, Hour, Day, Month and Weekday

    You can change the number 5 to another value if that suits your better. The number represents the amount of time in minutes between each backupsynchronization from RAM to the folder profile.
    After you are finished click Apply followed by Ok. Finally close Scheduled tasks.

    Now locate once again the file tmpfs_firefox.sh and move it to your home directory. After this is done rightclick on the file and choose Rename. Put an . infront of the name so the name of the file becomes .tmpfs_firefox.sh. This will make the file hidden in your homedirectory. Press refresh in Nautilus and the renamed filed should vanish. Press Ctrl + h to show hidden files and directories and you can easily locate the file if you want to.

    Now we just need to reboot the computer to make sure that everything works.
    After reboot open up a terminal and enter the command mount. If you see a line that is similar to mine it works.

    Code:
    firefox on /home/leif/.mozilla/firefox/rcw72e7n.default type tmpfs (rw,nosuid,nodev,size=200M,uid=1000,gid=1000,user=leif)
     
    Bossieman, Apr 11, 2009
    #1
  2. Bossieman

    Joe Foe from Buffalo

    Joined:
    Mar 7, 2009
    Messages:
    114
    Likes Received:
    0
    Location:
    Buffalo New York USA
    I haven't done all of the above...but so far I do notice it is faster with what I have done. Thank you for posting such good info.
     
    Joe Foe from Buffalo, Apr 14, 2009
    #2
  3. Bossieman

    Bossieman

    Joined:
    Aug 15, 2008
    Messages:
    20
    Likes Received:
    0
    Please post your thoughts after you completed the guide. I have a very much better system oaverall now.
     
    Bossieman, Apr 14, 2009
    #3
  4. Bossieman

    Joe Foe from Buffalo

    Joined:
    Mar 7, 2009
    Messages:
    114
    Likes Received:
    0
    Location:
    Buffalo New York USA
    I would if I could.....Honestly I stopped at these steps if you want to fix it or say it in a way that may help find them to keep going down the list of modifications

    The original author suggested to change the values for

    browser.safebrowsing.enabled to False

    browser.safebrowsing.malware.enabled to False


    cause I do not have what you posted and I should have in my listings to change them to what you say to change them to.
     
    Joe Foe from Buffalo, Apr 14, 2009
    #4
  5. Bossieman

    Bossieman

    Joined:
    Aug 15, 2008
    Messages:
    20
    Likes Received:
    0
    Sorry for the delay but the above means this:

    After you have entered about:config into the adressbar copy and paste the red line browser.safebrowsing.enabled into the filterbox. You should get one hit named browser.safebrowsing.enabled
    Look to the right of the line and you see either False or True. If the value is True dubbelklick on True to make it switch to False.

    After that is done copy and paste the blue line browser.safebrowsing.malware.enabled into the filterbox. You should get one hit named browser.safebrowsing.malware.enabled
    Look to the right of the line and you see either False or True. If the value is True dubbelklick on True to make it switch to False.

    Then continue the guide.
     
    Bossieman, Apr 16, 2009
    #5
  6. Bossieman

    Joe Foe from Buffalo

    Joined:
    Mar 7, 2009
    Messages:
    114
    Likes Received:
    0
    Location:
    Buffalo New York USA
    Thank you. Both are all ready set to false. Now I'm lost at the next step "After this is done, go to your .mozilla/firefox folder and create a folder there and name it profile" if your up to try to teach me more please post details.
     
    Joe Foe from Buffalo, Apr 18, 2009
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.