LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04:57 AM by number22
Updated 11-22-2017 at 11: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 566 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 04:01 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration