Change snap log location to reduce SD card wear


So I am running a small cluster of Raspberry Pi’s for dev (all running Ubuntu 22.04 LTS with a bunch of snaps) and have run into an optimization question. Namely, ways to reduce r/w to the micro sd cards of the RPIs by dealing with the frequent logging that happens.

Regular logs (/var/log) are kept on a ramdisk that is continually sent to our central logging solution then pruned, so they never touch the microSD card. Snap logs however is a whole other matter.

As an example, the LXD snap logs to /var/snap/lxd/common/lxd/logs, and logs frequently. I’d simply symlink each snaps log directory to the existing RAM disk, or even create a separate RAM disk for each, but worry about the security implications / amount of manual labor that requires for each snap.

Has anyone here has had any experience with this problem and found a good solution for moving the logging off the SD?

normally snap services simply log to systemd-journald and you should not need to do anything about them … seems lxd decided to log to an additional location along with that. other snaps might do as well, but i think that is rather the exception and you should be able to identify the few that do it …

symlinking something to the outside of the sandbox will not work, apparmor is explicitly not following symlinks to prevent apps from breaking out of confinement … you can use bind mounts instead of symlinks though.

1 Like

Bind mounts did the trick. Thank you very much for the help.