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

Wed Oct 4 08:42:13 UTC 2017
Anand Buddhdev <anandb at ripe.net>

On 04/10/2017 10:23, Gary Stainburn wrote:

Hi Gary,

> Mark, Many Non-Centos originated packages create directories in /var/run as 
> part of the install, and expect them to still exist after a reboot.

Those packages have been built poorly.

> They then fail when starting the service because they're trying to create a 
> PID / Lock file in a directory that no longer exists.  This problem has been 
> around ever since /var/run was moved to tmpfs.

Yes, and those packages should know how to work with CentOS 7.

> Unfortunately, sometimes we have to use packages other than the official 
> Centos ones, usually as in this case because we need newer versions.

Sure, that can be.

> There is a solution that saves /var/run to disk at shutdown and restores it at 
> bootup but I can't remember what it is.

There's no need to do that (and it's also messy). Instead, if a package
needs a directory to exist in /var/run, then create your own config for
systemd-tmpfiles, and drop it into /etc/systemd/tmpfiles.d. Work with
CentOS 7, instead of fighting with it.