[CentOS] how to prevent files and directories from being deleted?

Tue Oct 3 17:35:55 UTC 2017
Paul Heinlein <heinlein at madboa.com>

On Tue, 3 Oct 2017, hw wrote:

> Alexander Dalloz <ad+lists at uni-x.org> writes:
>
>> Am 01.10.2017 um 17:21 schrieb hw:
>>> Hi,
>>>
>>> how can I prevent files/directories like /var/run/mariadb from 
>>> being deleted on reboot?  Lighttpd has the same problem.
>>>
>>> This breaks services and makes servers non-restartable by anyone 
>>> else but the administrator who needs to re-create the needed files 
>>> and directories every time and has to figure out what selinux 
>>> labels they need.  This causes unnecessary downtimes.
>>>
>>> This is entirely inacceptable.  This totally sucks.

On CentOS 7 machines, the /run mountpoint (available via symlink as 
/var/run) is a temporary filesystem. Try "df -h /run" to see for 
yourself. That whole directory lives in memory.

Using systemd-tmpfiles is the most reliable method for ensuring your 
/run directories are created and given correct perms at boot. The 
syntax for /etc/tmpfiles.d/*.conf isn't terribly difficult, and the 
files there are easy to manage. See the tmpfiles.d(5) man page for 
details and examples.

Once your file is in place, you can activate it without messing with 
other temp files:

systemd-tmpfiles --create /etc/tmpfiles.d/your.conf

-- 
Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W