Temp thumbnail Cache using Systemd
I wanted to give a systemd update to this. This is just taking what @lukasrozs already said here https://askubuntu.com/a/809084/1242385 but uses systemd mounts rather than modifying /etc/fstab.
I'm going to assume your thumbnail cache is in a directory like /home/dephekt/.cache/thumbnails
and that the user you want to mount this for is UID & GID 1000.
The unit file
[Unit]
Description=Thumbnailer Cache tmpfs mount
ConditionPathIsSymbolicLink=!/home/dephekt/.cache/thumbnails
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs
Where=/home/dephekt/.cache/thumbnails
Type=tmpfs
Options=rw,mode=1755,relatime,nosuid,nodev,noexec,size=512M,uid=1000,gid=1000
[Install]
WantedBy=local-fs.target
Mount size
You can modify the size=256M
mount option to be whatever size you think is sufficient for the thumbnailer cache. I set this to 512M, since my the default maximum cache size for me is 512M. You can find that setting by doing:
$ gsettings get org.gnome.desktop.thumbnail-cache maximum-size
512
Unit file naming
The file needs to be named using the path you used in the Where=
argument above, but properly escaped. In my case, the Where=
path is /home/dephekt/.cache/thumbnails
. To easily determine how systemd would want this to look escaped, you can do:
$ systemd-escape --path --suffix=mount "/home/dephekt/.cache/thumbnails"
home-dephekt-.cache-thumbnails.mount
That gives you exactly what the filename should look like.
Placement & installation
Then place the file in /etc/systemd/system
and run:
sudo systemctl daemon-reload
sudo systemctl enable home-dephekt-.cache-thumbnails.mount
sudo systemctl start home-dephekt-.cache-thumbnails.mount
This should cause the mount to happen right now and also automatically after booting.
~/.thumbnails
then you should also be concerned that they may be watching your images that resulted in the creation of thumbnail files in the first place. The solution to that is usually, depending on the situation and your threat model, discretionary user access control or file or disk encryption.