1profile-sync-daemon(22 September 2020) profile-sync-daemon(22 September 2020)
2
3
4
6 profile-sync-daemon - Symlinks and syncs browser profiles to RAM
7 (tmpfs) thus reducing HDD/SSD calls and speeding up browsers.
8
10 Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage
11 browser profile/profiles in tmpfs and to periodically sync back to the
12 physical disc (HDD/SSD). This is accomplished by an innovative use of
13 rsync to maintain synchronization between a tmpfs copy and media-bound
14 backup of the browser profile/profiles. Additionally, psd features sev‐
15 eral crash-recovery features.
16
17 Design goals of psd:
18
19 · Completely transparent user experience.
20
21 · Reduced wear to physical discs (particularly SSDs).
22
23 · Speed.
24
25 Since the profile/profiles, browser cache*, etc. are relocated into
26 tmpfs (RAM disk), the corresponding I/O associated with using the
27 browser is also redirected from the physical disc to the RAM, thus
28 reducing wear to the physical disc and improving browser responsive‐
29 ness.
30
31 *Note that some browsers such as Chrome/Chromium, Firefox (since v21),
32 Midori, and Rekonq actually keep their cache directories separate from
33 their browser profile directory. It is not within the scope of profile-
34 sync-daemon to modify this behavior; users wishing to relocate this
35 directory, may refer to the following url for several work-arounds:
36 https://wiki.arch‐
37 linux.org/index.php/Chromium_Tips_and_Tweaks#Cache_in_tmpfs
38
40 $XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config
41 file") contains all user managed settings.
42
43 NOTE: edits made to the config file while psd is active will be applied
44 only after the service has been restarted.
45
46 · Optionally enable the use of overlayfs to improve sync speed
47 and to use a smaller memory footprint. Do this in the
48 USE_OVERLAYFS variable. The user will require no password
49 sudo rights to /usr/bin/psd-overlay-helper to use this option
50 and the kernel must support overlayfs version 22 or higher.
51 See the FAQ below for additional details.
52
53 · Optionally have psd resync to the filesystem prior to a sleep
54 call. This can help in the event that the system does not
55 properly wake up. Do this in the USE_SUSPSYNC variable.
56
57 · Optionally define which browsers are to be managed in the
58 BROWSERS array. If none are defined, the default is all
59 detected browsers.
60
61 · Optionally disable the use of crash-recovery snapshots (not
62 recommended). Do this in the USE_BACKUPS variable.
63
64 · Optionally define the number of crash-recovery snapshots to
65 keep. Do this in the BACKUP_LIMIT variable.
66
67 NOTE: occasionally, updates/changes are made to the default config file
68 (/usr/share/psd/psd.conf) upstream. The user copy ($XDG_CON‐
69 FIG_HOME/psd/psd.conf) will need to be diffed against it.
70
72 PREVIEW MODE
73 The preview option can be called to show users exactly what psd will
74 do/is doing based on the entries in the config file. It will also pro‐
75 vide useful information such as profile size, paths, and if any recov‐
76 ery snapshots have been created.
77
78 $ psd p
79
80 Profile-sync-daemon v6.39
81
82 systemd service: active
83 resync-timer: active
84 sync on sleep: enabled
85 use overlayfs: enabled
86
87 Psd will manage the following per /home/facade/.config/psd/.psd.conf settings:
88
89 browser/psname: chromium/chromium
90 owner/group id: facade/100
91 sync target: /home/facade/.config/chromium
92 tmpfs dir: /run/user/1000/facade-chromium
93 profile size: 93M
94 overlayfs size: 39M
95 recovery dirs: 2 <- delete with the c option
96 dir path/size: /home/facade/.config/chromium-backup-crashrecovery-20200423_171359 (92M)
97 dir path/size: /home/facade/.config/chromium-backup-crashrecovery-20200424_112204 (93M)
98
99 browser/psname: firefox/firefox
100 owner/group id: facade/100
101 sync target: /home/facade/.mozilla/firefox/f8cv8bfu.default
102 tmpfs dir: /run/user/1000/facade-firefox-f8cv8bfu.default
103
104 profile size: 145M
105 overlayfs size: 13M
106 recovery dirs: none
107
108
109 START AND STOP PSD
110 Psd ships with a systemd user service to start or stop it (psd.ser‐
111 vice). Additionally, a provided resync-timer will run an hourly resync
112 from tmpfs back to the disk. The resync-timer is started automatically
113 with psd.service so there is no need to start the timer; only start
114 psd.service.
115
116 $ systemctl --user [option] psd.service
117
118 Available options: start stop enable disable
119
120 CLEAN MODE
121 The clean mode will delete ALL recovery snapshots that have accumu‐
122 lated. Only run it when sure these are no longer needed.
123
124 $ psd c
125
126 Profile-sync-daemon v6.39
127
128 Deleting 2 crashrecovery dirs for profile /home/facade/.config/chromium
129 /home/facade/.config/chromium-backup-crashrecovery-20200423_171359
130 /home/facade/.config/chromium-backup-crashrecovery-20200424_112204
131
132
134 · Chromium (stable, beta, and dev)
135
136 · Conkeror
137
138 · Epiphany
139
140 · Falkon
141
142 · Firefox (stable, beta, and aurora)
143
144 · Firefox-trunk (this is an Ubuntu-only browser:
145 http://www.webupd8.org/2011/05/install-firefox-nightly-from-ubuntu-
146 ppa.html)
147
148 · Google Chrome (stable, beta, and dev)
149
150 · Heftig's version of Aurora (Arch Linux: https://bbs.arch‐
151 linux.org/viewtopic.php?id=117157)
152
153 · Icecat
154
155 · Iceweasel
156
157 · Inox (https://bbs.archlinux.org/viewtopic.php?id=198763)
158
159 · Luakit
160
161 · Midori
162
163 · Opera (legacy, stable, next, and developer)
164
165 · Otter-browser
166
167 · Palemoon
168
169 · QupZilla
170
171 · Qutebrowser
172
173 · Rekonq
174
175 · Seamonkey
176
177 · Vivaldi
178
179 · Vivaldi-snapshot
180
181 Psd's infrastructure can work in principal with any browser that uses a
182 generic chrome or mozilla, etc. format. User supplied profiles are pro‐
183 vided in /usr/share/psd/contrib/ and can be manually copied to
184 /usr/share/psd/browsers/ if one wishes to sync that particular browser.
185 Make a corresponding entry in the BROWSERS array within the config
186 file. Support for these is unsupported.
187
189 Currently, psd does not support symlinked profiles and will refuse to
190 sync if one is detected. For example, your firefox profile is
191 ~/.mozilla/firefox/f8cv8bfu.default but you have moved that directory
192 to /foo/bar/f8cv8bfu.default and replaced it with symlink:
193
194 $ ls -l ~/.mozilla/firefox
195 lrwxrwxrwx 1 facade users 26 Oct 1 17:02 f8cv8bfu.default -> /foo/bar/f8cv8bfu.default
196
197 Running psd in preview mode will end in an error informing you of this:
198
199 $ psd p
200
201 Warning!
202 /home/facade/.mozilla/firefox/f8cv8bfu.default appears to be a symlink but these are not supported.
203 Please make the browser profile a live directory and try again. Exiting.
204
205 A proper work around for firefox is to simply edit ~/.mozilla/fire‐
206 fox/profiles.ini defining the canonical path there. One also needs to
207 adjust the IsRelative flag like so:
208
209 [Profile0]
210 Name=default
211 IsRelative=0
212 Path=/foo/bar/f8cv8bfu.default
213
214 Other solutions may exist for other browsers but documenting them all
215 here is out of scope.
216
218 Since psd is just a bash script with a systemd service, it should run
219 on any flavor of Linux running systemd. Several distros provide an
220 official package or user-maintained option to install psd. One can also
221 build psd from source. See the official website for available packages,
222 dependencies, and installation instructions
223
225 Q1: What is overlayfs mode?
226
227 A1: Overlayfs is a simple union filesystem mainlined in the Linux ker‐
228 nel version 3.18.0. When used with psd, a reduced memory footprint and
229 faster sync operations can be realized. The magic is in how the overlay
230 mount only writes out data that has changed rather than the entire pro‐
231 file. The same recovery features psd uses in its default mode are also
232 active when running in overlayfs mode.
233
234 See the example in the PREVIEW MODE section above which shows a system
235 using overlayfs to illustrate the typical memory savings. Note the
236 "overlayfs size" report compared to the total "profile size" report for
237 each profile. Be aware that these numbers will change depending on just
238 how much new data is written to the profile, but in common use cases,
239 the overlayfs size will always be less than the profile size.
240
241 Q2: How do I enable overlayfs mode?
242
243 A2: First, be sure psd is not active or else any changes to the config
244 file will be ignored until it is restarted. Overlayfs mode is enabled
245 with the USE_OVERLAYFS= variable which should be set to "yes" in the
246 config file. Psd will automatically detect the overlayfs version avail‐
247 able to the kernel if it is configured to use one of them. It is recom‐
248 mended to run psd in preview mode to verify that the system can in fact
249 use overlayfs.
250
251 Users wanting to use overlayfs mode MUST have sudo rights without pass‐
252 word prompt to /usr/bin/psd-overlay-helper or global sudo rights with‐
253 out password prompt. If the user does not have global rights, add the
254 following line to /etc/sudoers after any other lines defining sudo
255 access. It is recommended to use /usr/bin/visudo as root to set this
256 up:
257
258 foo ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper
259
260 Q3: Why do I have another browser profile directory "foo-back-ovfs"
261 when I enable overlayfs?
262
263 A3: The way overlayfs works is to mount a read-only base copy (so-
264 called lower dir) of the profile, and manage the new data on top of
265 that. In order to avoid resyncing to the read-only filesystem, a copy
266 is used instead. So using overlayfs is a trade-off: faster initial sync
267 times and less memory usage vs. disk space in the home dir.
268
269 Q4: I need more memory to accommodate my profile/profiles in
270 /run/user/xxxx. How can I allocate more?
271
272 A4: The standard way of controlling the size of /run/user/ is the Run‐
273 timeDirectorySize directive in logind.conf (see the man page for
274 logind.conf for more). By default, 10% of physical memory is used but
275 one can increase it safely. Remember that tmpfs only consumes what is
276 actually used; the number specified here is just a maximum allowed.
277
278 Q5: My system crashed for some reason and psd didn't sync back. What do
279 I do?
280
281 A5: The "last good" backup of the browser profile/profiles should be
282 the filesystem. Upon restarting psd (on a reboot for example), a check
283 is performed to see if the symlink to the tmpfs copy of the profile is
284 invalid. If it is invalid, psd will snapshot the "last good" backup
285 before it rotates it back into place. This is more for a sanity check
286 that psd did no harm and that any data loss was a function of something
287 else.
288
289 Q6: Where can I find this snapshot?
290
291 A6: It depends on the browser. The snapshot will be located in the same
292 directory as the browser profile and it will contain a date-time-stamp
293 that corresponds to the time at which the recovery took place. For
294 example, a chromium snapshot will be ~/.config/chromium-backup-crashre‐
295 covery-20130912_153310 -- of course, the date_time suffix will be dif‐
296 ferent.
297
298 Q7: How can I restore the snapshot?
299
300 A7: Follow these steps:
301
302 1. Stop psd.
303
304 2. Move the "bad" copy of the profile to a backup (don't
305 blindly delete anything).
306
307 3. Copy the snapshot directory to the name that browser
308 expects.
309
310 Example using chromium:
311
312 1. systemctl --user stop psd.service
313
314 2. mv ~/.config/chromium ~/.config/chromium-bad
315
316 3. cp -a ~/.config/chromium-backup-crashrecov‐
317 ery-20130912_153310 ~/.config/chromium
318
319 At this point, launch chromium which will use the backup snapshot just
320 copied into place. If all is well, it is safe to delete ~/.con‐
321 fig/chromium-bad and the snapshot. Remember, to start psd, no browsers
322 must be open (or psd will refuse to start).
323
324 Q8: Can psd delete the snapshots automatically?
325
326 A8: Yes, run psd with the "clean" switch to delete snapshots.
327
329 Users wishing to contribute to this project, should fork it and send a
330 pull request. Source is freely available on github.
331
333 Discovered a bug? Please open an issue.
334
335 · Several cases of data loss have been reported when using
336 eCryptFS and psd, therefore until this issue is flushed out,
337 users of eCryptFS are encouraged not to use psd unless will‐
338 ing to help troubleshoot suspected browser corruption. See:
339 https://github.com/graysky2/profile-sync-daemon/issues/158
340
342 · Project page: https://github.com/graysky2/profile-sync-daemon
343
344 · Wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon
345
347 graysky (graysky AT archlinux DOT us)
348
349
350
351 profile-sync-daemon(22 September 2020)