LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > number22
User Name
Password

Notices


Rate this Entry

Move firefox profile and cache into RAM tmpfs.

Posted 11-22-2017 at 03:57 AM by number22
Updated 11-22-2017 at 10:48 AM by number22

Relocating firefox's profile and cache into tmpfs of RAM; speed up firefox and save your hard drive's lifespan and space.

Change XXXX.UserProfile to exactly to your path of course.

creating backup locations first:
Code:
mkdir ~/backup/firefox.profile
mkdir ~/backup/firefox.cache
chmod 700 ~/backup/firefox.*
edit your /etc/fstab add following lines files will be mounted on firefox original locations, profile and cache:
Code:
tmpfs  your_home/.mozilla/firefox/XXXX.UserProfile   tmpfs size=250M,user,exec,uid=uid#,gid=100   0     0

tmpfs  your_home/.cache/mozilla/firefox/XXXX.UserProfile  tmpfs size=250M,user,exec,uid=uid#,gid=100   0     0
Before you mount these drives, you need backup all its files, and clean these space, needs root to mount all these new ram drive partitions.

Code:
cd ~/.mozilla/firefox/XXXX.UserProfile
cp -a * ~/backup/firefox.profile
cd ~/.cache/mozilla/firefox/XXXX.UserProfile
cp -a * ~/backup/firefox.cache
Add following lines into your .bash_profile, which will copy your backup firefox cache and profile into memory disk whenever you login.
Code:
if [ "$(find $HOME/.mozilla/firefox/XXXX.UserProfile/ -maxdepth 0 -empty)" ]; then
   rsync -ah $HOME/backup/firefox.profile/   $HOME/.mozilla/firefox/XXXX.UserProfile/ --delete-before
else
   echo -n "firefox profile is already filled ";
fi

if [ "$(find $HOME/.cache/mozilla/firefox/XXXX.UserProfile/ -maxdepth 0 -empty)" ]; then
   rsync -ah $HOME/backup/firefox.cache/    $HOME/.cache/mozilla/firefox/XXXX.UserProfile/ --delete-before
else
   echo " cache is already restored";
fi

sleep 0.1
now creating a script to manual sync your firefox profile and cache, which can be used by cron job too:

vim ~/sbin/firefox_sync

Code:
#!/bin/sh
#check both directory exist then back up when there is no lock file inside firefox profile 
if [[ -d ~/.mozilla/firefox/XXXX.UserProfile ] && [-d ~/.cache/mozilla/firefox/XXXX.UserProfile]] && [[ -d ~/backup/firefox.profile ] && [-d ~/backup/firefox.cache ]]; then
if [ -L ~/.mozilla/firefox/XXXX.UserProfile/lock ]; then
   echo "lock file exist"
   exit 1
else
rsync -ah ~/.mozilla/firefox/XXXX.UserProfile/  ~/backup/firefox.profile/ --delete-before
rsync -ah  ~/.cache/mozilla/firefox/XXXX.UserProfile/ ~/backup/firefox.cache/ --delete-before
fi;
fi

sleep 0.1
exit 0
save it then chmod 700 make it manually executable. You can use this script in .bash_logout or crontab -e .

Go to firefox preference, security and privacy; override automatic cache management and change its size to anything less than 250MB.or modify firefox's options in user.js/about:config:
Code:
user_pref("browser.cache.disk.capacity", 234496);
user_pref("browser.cache.disk.smart_size.enabled", false);
user_pref("browser.cache.disk.smart_size.first_run", false);
user_pref("browser.cache.memory.enable", false);
more info of user.js you can consult with kb.mozillazine.org/User.js_file and or ghacks.net user.js
Good luck.
Posted in Uncategorized
Views 5361 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    This is a great guide, very similar to this one. Would you know on Linux how to affect all profiles, e.g., some where in the /usr/lib64/firefox path?
    Posted 01-25-2018 at 11:05 AM by RobbieTheK RobbieTheK is offline
 

  



All times are GMT -5. The time now is 06:50 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration