16.04 LTS and /dev/shm/ Files Disappearing
I am migrating a web application that was previously running on Ubuntu 12.04 LTS. It makes extensive use of /dev/shm/
. I'm finding that the application data is disappearing from /dev/shm/
on the Ubuntu 16.04 LTS server.
Is there some sort of garbage collection that's deleting the files and directories from there? I see that 12.04 is configured with this symbolic link: /dev/shm -> /run/shm
, whereas 16.04 has exactly the opposite: /run/shm -> /dev/shm
. I don't see how that would make any difference, though.
UPDATES
- I suspected AppArmor, but removing it did not change the behavior
- The removal of the directory structures seems to happen every five minutes
- Directories with files in them eventually get deleted, but not as quickly
- I'm suspecting the age of the files/directories affects deletion
- It looks like this guy is experiencing the same issue.
After hours of searching and reading, I found the culprit. It's a setting for systemd
. The /etc/systemd/logind.conf
contains default configuration options, with each of them commented out. The RemoveIPC
option is set to yes
by default. That option tells systemd
to clean up interprocess communication (IPC) for "user accounts" who aren't logged in. This does not affect "system accounts"
In my case, the files and directories were being created for a user account, not a system account.
There are two possible solutions:
- Create the files with/for a system user -- a user created with the system option (
adduser -r
oradduser --system
) - Edit
/etc/systemd/logind.conf
, uncomment the lineRemoveIPC=yes
, change it toRemoveIPC=no
, save, and reboot the system
In my case, I went with option #2 because the user was already created.
References:
- RemoveIPC prematurely removes IPC segments
- Change default value of RemoveIPC in logind.conf
- PostgreSQL: Systemd
- Oracle: 3.5 Database Installation and Operation Fails if RemoveIPC=yes Is Configured for systemd