Tmpfs Tools Profile Sync Daemon (PSD): Difference between revisions
m (Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Linux Desktop) |
m (Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Linux Desktop) |
||
Line 102: | Line 102: | ||
| Прндл = Linux Desktop | | Прндл = Linux Desktop | ||
| Прндл1 = Linux Server | | Прндл1 = Linux Server | ||
| Стадий = | | Стадий = 5 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Авторизиран | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = Spas | | РзбПт = Spas | ||
| АвтПт = {{REVISIONUSER}} | | АвтПт = Spas | ||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 31.08.2022 | | ИдтДт = 31.08.2022 | ||
| РзбДт = 31.08.2022 | | РзбДт = 31.08.2022 | ||
| АвтДт = {{Today}} | | АвтДт = 31.08.2022 | ||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/30872|30872]] | | ИдтРв = [[Special:Permalink/30872|30872]] | ||
| РзбРв = [[Special:Permalink/30883|30883]] | | РзбРв = [[Special:Permalink/30883|30883]] | ||
| АвтРв = {{REVISIONID}} | | АвтРв = [[Special:Permalink/30884|30884]] | ||
| УтвРв = {{REVISIONID}} | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Revision as of 15:13, 31 August 2022
Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser's profile in tmpfs
and to periodically sync it back to your physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync
to maintain back-up and synchronization between the two. One of the major design goals of psd
is a completely transparent user experience.
It is designed to work on desktop systems, but by creating custom fake profiles it could be used for non production servers :) Currently I'm using it to minimize Brave browser disk writings. More information about the PSD's Brave profile could be foun in the references section below.
Identify the Problem
sudo watch -d -n 1 "find ~/.cache ~/.config -type f -size +80k -mmin -10 -printf '%-30s \t %t %p\n'"
du -hs ~/.cache ~/.config
iostat -h /dev/nvme0n1 -d 60 -t
Install PSD
The PSD tool is available as package for many Linux distributions. Here is how to install on Debian/Kali.
sudo apt install profile-sync-daemon
However the Debian's package is little bit older but works stable. If you want the latest version install it from its GitHub repository by performing the following steps.
cd ~/Git # or ~/Downloads or where you prefer
git clone https://github.com/graysky2/profile-sync-daemon.git
cd profile-sync-daemon
make
sudo make install
Setup PSD
Within the latest version on GitHub is available a profile for Brave browser also there is a discussion about it. However I prefer to create two custom profiles: 1) the first will handle ~/.config/BraveSoftware/Brave-Browser
, and 2) the second will handle ~/.cache/BraveSoftware/Brave-Browser
.
echo -e 'DIRArr[0]="$XDG_CONFIG_HOME/BraveSoftware/Brave-Browser"\nPSNAME="brave"' | \
sudo tee /usr/share/psd/browsers/brave
echo -e 'DIRArr[0]="'"$HOME"'/.cache/BraveSoftware/Brave-Browser"\nPSNAME="brave-cache"' | \
sudo tee /usr/share/psd/browsers/brave-cache
The next step is to add brave and brave-cache to the PSD user's configuration file – psd.conf
.
echo -e '\nBROWSERS="brave brave-cache"' >> ~/.config/psd/psd.conf
I prefer also to enable the use of overlayfs
mode to improve sync speed and to use a smaller memory footprint. The first thing according to that is to add entry in the psd.conf
file, and also an entry into the sudoers.d
directory, because this feature requires more permissions.
echo -e '\nUSE_OVERLAYFS="yes"' >> ~/.config/psd/psd.conf
echo "$USER ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" | \
sudo tee -a /etc/sudoers.d/psd-overlay-helper
- Note it is better and save to use just
echo "$USER ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper"
to generate the line and the usesudo visudo /etc/sudoers.d/psd-overlay-helper
.
In addition you can enable the suspend-sync feature.
echo -e '\nUSE_SUSPSYNC="yes"' >> ~/.config/psd/psd.conf
This feature requires glib2
library, it could be installed on nowadays Debian/Ubuntu/Kali/etc. via the following command.
sudo apt install libglib2.0-dev
Usage
You can use man psd
to get detailed information. However here are few essential commands.
PREVIEW MODE. The preview option can be called to show users exactly what psd
will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and if any recovery snapshots have been created.
psd p
Profile-sync-daemon v6.45
systemd service: active
resync-timer: active
sync on sleep: disabled
use overlayfs: enabled
Psd will manage the following per /home/<user>/.config/psd/.psd.conf:
browser/psname: brave/brave
owner/group id: <user>/1000
sync target: /home/<user>/.config/BraveSoftware/Brave-Browser
tmpfs dir: /run/user/1000/psd/<user>-brave
profile size: 420M
overlayfs size: 85M
recovery dirs: none
browser/psname: brave-cache/brave-cache
owner/group id: <user>/1000
sync target: /home/<user>/.cache/BraveSoftware/Brave-Browser
tmpfs dir: /run/user/1000/psd/<user>-brave-cache
profile size: 277M
overlayfs size: 21M
recovery dirs: none
START AND STOP PSD. Psd ships with a systemd user service to start or stop it (psd.service
). Additionally, a provided resync-timer
will run an hourly resync
from tmpfs
back to the disk. The resync-timer
is started automatically with psd.service
so there is no need to start the timer; only start psd.service
.
systemctl --user status psd.service
systemctl --user start psd.service
systemctl --user stop psd.service
systemctl --user enable psd.service
systemctl --user disable psd.service
Tweak the rsync-timer
.
systemctl --user cat psd-resync.timer
systemctl --user edit psd-resync.timer
CLEAN MODE. The clean mode will delete ALL recovery snapshots that have accumulated. Only run it when sure these are no longer needed.
psd c
References
- GitHub: Profile-sync-daemon (psd) | Add Brave Browser #240
- ArchLinux Wiki: Profile-sync-daemon
- ArchLinux Wiki: Firefox/Profile on RAM
- ArchLinux Wiki: Chromium/Cache in tmpfs
- ArchLinux Wiki: XDG Base Directory