How To Sync Browser Profile Into Tmpfs (RAM) In Linux
This tutorial explains how to sync browser profile into Tmpfs (RAM) to improve browser speed in Linux. We can sync the profile(s) manually or using some tools. In this guide, we are going to do it using one such tool named Profile-sync-daemon (shortly psd). The Profile-sync-daemon tool is nothing but a BASH script designed to manage browser’s profile(s) in tmpfs and synchronize them periodically with the help of Rsync to the HDDs and/or SSDs. As you may already know, Tmpfs is a temporary filesystem that resides in Memory or Swap partitions. So moving browser’s profile will effectively increase overall performance of your browser.
Moving your browser’s profile to RAM offers two significant benefits:
- Reduces hard disk read/write, especially improves the I/O operations in SSDs.
- Improves your web browser’s speed and responsiveness.
One caveat to this approach is that it will slow down login, because your browser’s profiles are copied to RAM while logging in.
Profile-sync-daemon scripts allows us to manage profiles of almost all web browsers including the following:
- Google Chrome
- Opera, Opera-Beta, Opera-Developer, and Opera-Legacy
- Vivaldi-browser and Vivaldi-browser-snapshot
Install Profile-sync-daemon On Linux
Since Profile-sync-daemon is just Bash script, it can be installed on many Linux distributions. Good thing is it is available in the official repositories of some Linux distributions.
On Arch Linux and its variants like Manjaro Linux, install Psd using Pacman like below.
$ sudo pacman -S profile-sync-daemon
On Debian Sid/10/ 9, Ubuntu 19.10/18.04:
$ sudo apt install profile-sync-daemon
On Fedora 31/30, CentOS 8 and other distributions that have DNF installed:
$ sudo dnf copr enable szasza/Profile-sync-daemon
$ sudo dnf install profile-sync-daemon
On other distributions, make sure you have the following dependencies installed:
- bash >=4.0
And then download the Profile-sync-daemon latest version from the releases page and install it manually. Refer the INSTALL text document included in the installation file to know how to install it. Installing from source usually like below:
$ sudo make install
Backup browser profiles
Before start using Psd in the first time, it is highly recommended to backup your browser’s profile. For instance, if you’re using Mozilla Firefox, all your bookmarks, saved passwords, extensions and plugins are stored in a special folder called Profile. It is usually stored in a separate location other than your Firefox installation directory. So if Firefox is crashed or something went wrong, you can easily restore the profile folder.
In Linux desktops, Firefox profile folder will usually be stored in ~/.mozilla location.
$ ls ~/.mozilla extensions firefox systemextensionsdev
Go to this location and backup the entire firefox folder and keep it a safe a location.
Also, the refer Firefox’s official documentation page to backup and restore profiles.
For other browsers, refer their official documentation.
Sync Browser Profile Into Tmpfs (RAM) In Linux Using Profile-sync-daemon
First, create Psd configuration file by running command:
This will create psd.conf file in /home/$USER/.config/psd/ directory.
First time running psd so please edit /home/sk/.config/psd/psd.conf to your liking and run again.
Now edit the psd configuration file:
$ nano /home/sk/.config/psd/psd.conf
Find the BROWSERS line, uncomment it by removing the # symbol and add your browsers separated by spaces.
[...] BROWSERS="chromium firefox" [...]
You can add as many as browsers you wanted by mentioning them space-separated. If there are no browsers defined, Psd will sync all supported browsers. Save and close the file.
Please note that any changes made to the psd.conf file will be applied only after psd service has been started and/or restarted.
Enable and start psd service:
$ systemctl --user enable psd
$ systemctl --user start psd
Verify if psd service has been started or not:
$ systemctl --user status psd ● psd.service - Profile-sync-daemon Loaded: loaded (/usr/lib/systemd/user/psd.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2020-03-18 15:45:54 IST; 8s ago Docs: man:psd(1) man:profile-sync-daemon(1) https://wiki.archlinux.org/index.php/Profile-sync-daemon Process: 11172 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 11172 (code=exited, status=0/SUCCESS) Mar 18 15:45:54 ostechnix systemd: Starting Profile-sync-daemon... Mar 18 15:45:54 ostechnix systemd: Started Profile-sync-daemon.
Psd service is enabled and started!
From now on, Profile-sync-daemon will copy your browser’s profiles to tmpfs (RAM) at the start-up and will sync them between your HDD/SSD and RAM periodically. It also maintains backup of the profiles in your physical disk.
Preview the Profile-sync-daemon settings
You can preview what exactly Psd is doing by passing the option -p.
$ psd p
Profile-sync-daemon v6.31 on Ubuntu 18.04.4 LTS Systemd service is currently active. Systemd resync-timer is currently active. Overlayfs technology is currently inactive. Psd will manage the following per /home/sk/.config/psd/psd.conf: browser/psname: chromium/chromium owner/group id: sk/1000 sync target: /home/sk/.config/chromium tmpfs dir: /run/user/1000/sk-chromium profile size: 32M recovery dirs: none browser/psname: firefox/firefox owner/group id: sk/1000 sync target: /home/sk/.mozilla/firefox/htoypxlg.default-1563118799416 tmpfs dir: /run/user/1000/sk-firefox-htoypxlg.default-1563118799416 profile size: 245M recovery dirs: none
As you can see, Psd running in my Ubuntu 18.04 desktop is managing two browser’s profiles i.e. Chromium and Firefox. It also displays other useful details such as browser name, owner/group id, profile size, sync target and tmpfs directory path.
Verify if Profile-sync-daemon is working
To verify if Profile-sync-daemon is actually syncing the browser’s profile, check your tmpfs directory path. In my case, it is /run/user/1000. You can find the path of tmpfs in the output of “psd p” command.
$ ls /run/user/1000
bus gnome-shell psd.pid snapd-session-agent.socket dbus-1 gnupg pulse systemd dconf gvfs sk-chromium update-notifier.pid gdm keyring sk-firefox-htoypxlg.default-1563118799416
View tmpfs sync directory from file manager:
Let us check size of the profile folder in tmpfs:
$ du -sh /run/user/1000/sk-firefox-htoypxlg.default-1563118799416/ 236M /run/user/1000/sk-firefox-htoypxlg.default-1563118799416/
..and size of Firefox’s default profile folder:
$ du -sh ~/.mozilla/firefox/htoypxlg.default-1563118799416 0 /home/sk/.mozilla/firefox/htoypxlg.default-1563118799416
As you see, the profile folder’s size in tmpfs is 236M, but default profile folder’s size is zero. Because, it is just a Symlink that points to another directory in tmpfs i.e. /run/user/1000/sk-firefox-htoypxlg.default-1563118799416/.
You can verify it using command:
$ readlink ~/.mozilla/firefox/htoypxlg.default-1563118799416 /run/user/1000/sk-firefox-htoypxlg.default-1563118799416
So, Firefox browser’s profile is loaded in the tmpfs (i.e. RAM).
When you reboot the system, the profiles will be synced to the physical disk and then copied back to the RAM when you login again.
Change sync intervals
By default, Profile-sync-daemon runs every one hour. You can, however, change it as per your wish by setting up a cron job for psd.
$ crontab -e
Set the time when you want to run Psd:
*/15 * * * * /usr/bin/profile-sync-daemon sync &> /dev/null
The above job will run Psd at every quarter hour (i.e every 15th minute). For more examples, please refer our Cron jobs manual.
Clean recovery snapshots
To delete all recovery snapshots, run:
$ psd c
Please do it only if you don’t need the snapshots anymore.
For more details, refer the official resources given below.