Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[HowTo] Move browser profile and cache to RAM

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

[HowTo] Move browser profile and cache to RAM

#1 Post by sunrat »

A simple how-to for set up of the profile-sync-daemon package which I found is an easy way to achieve moving browser profiles to RAM, and how-to move Firefox cache to RAM. A great way to reduce disk writes especially for SSDs.
Move browser profile to RAM
Install (as root or sudo):

Code: Select all

apt install profile-sync-daemon
Then preview (preview requires /usr/sbin/modinfo which is not in user PATH by default, so export it to temporarily add to PATH first):

Code: Select all

export PATH=/usr/sbin:$PATH && psd p
This will create the config file ~/.config/psd/.psd.conf where you can choose a few options but very simple. The only thing I did is specify it only to move Firefox profile. psd supports most browsers.
The package install creates a systemd service which runs automatically.
To load a newly edited config, just stop and restart the service:

Code: Select all

systemctl --user stop psd.service
systemctl --user start psd.service
#and to check status:
systemctl --user status psd.service
That's about all! :wink:

This Debian page contains more info:
https://manpages.debian.org/testing/pro ... .1.en.html
Arch wiki has a little extra info but is basically the same:
https://wiki.archlinux.org/title/Profile-sync-daemon

Move Firefox cache to RAM:
Simple change in about:config
Get your user ID with id -u
then set browser.cache.disk.parent_directory to /run/user/UID/firefox . You will probably need to create that as a new config entry.
For me and most single users it will be 1000, so mine is

Code: Select all

browser.cache.disk.parent_directory  /run/user/1000/firefox
You can confirm cache location with about:cache.


fatrace
The thing that prompted me to do this was running a nice little utility called fatrace which displays all disk access in real time. The number of accesses when running Firefox was astounding so I determined to do something about it. Comparing the disk accesses from before activating profile-sync-daemon and after proved how well it was working.
To run fatrace, first install it (as root or sudo):

Code: Select all

sudo apt install fatrace
then run

Code: Select all

sudo fatrace
Run it before and after making the changes and observe. :wink: 8)

Edited 19/03/23 to add PATH instruction and cache section. Edited 29/03/23 to clarify cache config entry.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: [HowTo] Move browser profile to RAM

#2 Post by sunrat »

Update re the PATH issue during first setup. I have removed /usr/sbin/ from my user PATH now and profile-sync-daemon is still working. I guess it just needed to access modinfo during first setup.

Theoretically, with this revelation, it should be sufficient to temporarily add /usr/sbin to user path before running the initial setup with psd p
To temporarily add to PATH, just run as user:

Code: Select all

export PATH=/usr/sbin:$PATH
Then run psd p in the same terminal. PATH will revert to previous upon closing that terminal.
I'd appreciate if someone could test this and let me know if it works so I can add it to the first post how-to (don't want to undo my setup).

profile-sync-daemon really does save an incredible amount of disk access on my SSD.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
donald
Debian Developer, Site Admin
Debian Developer, Site Admin
Posts: 1046
Joined: 2021-03-30 20:08
Has thanked: 186 times
Been thanked: 240 times

Re: [HowTo] Move browser profile to RAM

#3 Post by donald »

@Best_Threads
Typo perfectionish.


"The advice given above is all good, and just because a new message has appeared it does not mean that a problem has arisen, just that a new gremlin hiding in the hardware has been exposed." - FreewheelinFrank

dlu2021
Posts: 198
Joined: 2021-08-13 19:55
Location: Minnesota
Has thanked: 7 times
Been thanked: 37 times

Re: [HowTo] Move browser profile to RAM

#4 Post by dlu2021 »

sunrat wrote: 2023-03-18 04:40 I'd appreciate if someone could test this and let me know if it works so I can add it to the first post how-to (don't want to undo my setup).
I can confirm that it works and the service is still running after a reboot. I did find out that you still need to temporarily add the path any time that run psd from the terminal, like "psd p" for example to show the current status of it.

Just out of curiosity, did you do anything to move the Firefox cache to RAM as well?

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: [HowTo] Move browser profile to RAM

#5 Post by sunrat »

dlu2021 wrote: 2023-03-18 18:43
sunrat wrote: 2023-03-18 04:40 I'd appreciate if someone could test this and let me know if it works so I can add it to the first post how-to (don't want to undo my setup).
I can confirm that it works and the service is still running after a reboot. I did find out that you still need to temporarily add the path any time that run psd from the terminal, like "psd p" for example to show the current status of it.
Thank you very much for that. Good to know. So when one wants to run psd p , the PATH should be exported first:

Code: Select all

export PATH=/usr/sbin:$PATH && psd p
I will edit the first post to include that.
Just out of curiosity, did you do anything to move the Firefox cache to RAM as well?
Certainly, did that long ago. It's a simple change in about:config
Get your user ID with

Code: Select all

id -u
then set browser.cache.disk.parent_directory to /run/user/UID/firefox
For me and most single users it will be 1000, so mine is

Code: Select all

browser.cache.disk.parent_directory  /run/user/1000/firefox
Edited first post to add cache instruction.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

dlu2021
Posts: 198
Joined: 2021-08-13 19:55
Location: Minnesota
Has thanked: 7 times
Been thanked: 37 times

Re: [HowTo] Move browser profile and cache to RAM

#6 Post by dlu2021 »

Glad to help.

User avatar
kalle123
Posts: 346
Joined: 2015-03-21 11:17
Location: Rhineland - Germany
Has thanked: 4 times
Been thanked: 11 times

Re: [HowTo] Move browser profile and cache to RAM

#7 Post by kalle123 »

About that modification in firefox 'Move Firefox cache to RAM:' I am a bit puzzled.

On my main computer here there was an entry browser.cache.disk.parent_directory with option true or false.

I removed that with the line you advised.

On two others computers here (also on Debian) I am missing such an entry in firefox.

Can not remember that I fiddled with that browser.cache.disk.parent_directory thing before, but maybe I forgot.

br - KH :wink:

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: [HowTo] Move browser profile and cache to RAM

#8 Post by sunrat »

kalle123 wrote: 2023-03-28 14:05 About that modification in firefox 'Move Firefox cache to RAM:' I am a bit puzzled.

On my main computer here there was an entry browser.cache.disk.parent_directory with option true or false.

I removed that with the line you advised.

On two others computers here (also on Debian) I am missing such an entry in firefox.

Can not remember that I fiddled with that browser.cache.disk.parent_directory thing before, but maybe I forgot.
I haven't heard of a true or false entry for that. Can't imagine it would work as it requires a location. Perhaps you have fiddled with it. (I'm a chronic fiddler too. I try to write down changes I make but don't always remember).

The entry doesn't exist by default IIRC, you need to create it. I will clarify that in the original post. You can check cache location with about:cache.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
kalle123
Posts: 346
Joined: 2015-03-21 11:17
Location: Rhineland - Germany
Has thanked: 4 times
Been thanked: 11 times

Re: [HowTo] Move browser profile and cache to RAM

#9 Post by kalle123 »

You are right, sunrat. I think. I might have fiddled with that ...

So I made a backup of my bookmarks and passwords, renamed the .mozilla folder to .mozilla.backup and restarted firefox.

No entry in about:config with browser.cache.disk.parent_directory

This entry has to be created! My fault ....

Regards - KH

PS. One remark to your excellent HowTo.
This will create the config file ~/.config/psd/.psd.conf where you can choose a few options but very simple.
I think, there are two steps here:

- a file ~/.config/psd/psd.conf is generated, where you have to make your settings
- and then you'll find a much shorter file with your settings ~/.config/psd/.psd.conf

but please correct me, if a am wrong .... :wink:

Post Reply