lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

systemd deletes files in /run/shm

Mon Nov 12, 2018 5:12 pm

I have just done the usual sudo apt-get update and sudo apt-get upgrade and one of the changes was a systemd upgrade to version 232-25+deb9u4

A new "feature" in this update had some bad unintended consequences for me. In case it affects anybody else here are the details...

Since my first raspberry pi I have tried to reduce SDcard wear by putting small files that are frequently changed in /run/shm/. I never had any problems (unless you fill up tmpfs) even if you leave files there for a while.

However the new version of systemd finally implements the "RemoveIPC" directive in /etc/systemd/logind.conf. For me this means that whenever a systemd session (eg ssh) terminates, systemd tidies up all remaining "interprocess communication" for that user. I guess this is good to avoid resource hogging, but it also deletes all files in /run/shm/ that are owned by that user, even if they weren't put there during that session.

Fortunately there are a number of solutions:
1. Move the files somewhere else that is not deleted by systemd (I haven't tried this)
2. Change the user to any "system user" - where the UID is 999 or less (normally the user pi has the UID 1000)
3. Add the line "RemoveIPC=no" in /etc/systemd/logind.conf and reboot.

I am using option 3 and so far it seems fine.

Sorry if I haven't explained this very well. Hopefully it might help someone if they have the same problem.

Return to “Troubleshooting”