Home Home > 2010 > 05 > 03 > Preparation for Mounting /var/run as tmpfs
Sign up | Login

Deprecation notice: openSUSE Lizards user blog platform is deprecated, and will remain read only for the time being. Learn more...

Preparation for Mounting /var/run as tmpfs

May 3rd, 2010 by

Feature #303793 proposes to mount /var/run as tmpfs.

The description says:

“This would avoid the cleaning of stale files or sockets on bootup and avoid atime updates of any mounted filesystems. This is required for eg powermanagement, which currently wakes up the system from any idle states for a socket operation.

Services must be modified not to depend on a preexisting content in /var/run upon startup. RPMs must be modified to not place anything there.”

A rpmlint check has now been implemented to catch files packaged in /var/run to notify package maintainers of this.  This output of the rpmlint check is e.g.:

hal.x86_64: E: dir-or-file-in-var-run (Badness: 900) /var/run/hald/hald-runner

So, what options do we have to fix this in packages?

  • Check that /var/run is the right place. If you have a home directory in /var/run with content, consider using /var/lib and remember to handle the update of the package for users, e.g. use “usermod” in the post install script of the package to change existing users.
  • Create the directory on invocation of your program.  Many programs already do this, so you might not need to make any changes.
  • Otherwise you have the following options:
    • have the program itself check for the directory and create it with correct permissions
    • if the program is normally invoked from an init script, enhance the init script to do this, e.g.:
      if [ ! -d $HALDAEMON_PIDDIR ]; then
      mkdir -p $HALDAEMON_PIDDIR
      chown haldaemon:haldaemon $HALDAEMON_PIDDIR
      fi
      or use install directly, like install -d -g haldaemon -o haldaemon $HALDAEMON_PIDDIR
    • Place a script in /etc/tmpdirs.d that creates the directories and files, you can look at /etc/tmpdirs.d/01_aaa_base from package aaa_base for an example.
    • Note that the first option is the preferred one since it does not invoke calling of any other programs, the second one comes next since for both the first and the second one the directories are only created when needed – and the last one is something for directories that are always needed since it’s called at every boot.
  • Make the file or directory known to rpm but do not package it – use %ghost in the rpm spec file list, e.g.:
  • %attr(-,avahi,avahi) %ghost %{_localstatedir}/run/avahi-daemon

Both comments and pings are currently closed.

3 Responses to “Preparation for Mounting /var/run as tmpfs”

  1. Dinar Valeev

    xl2tpd fixed

  2. Zarantu

    Greetings,

    Perhaps could use a UnionFS for more transparency:
    populate /var/run.vfs from scripts in /etc/tmpdirs.d
    leave /var/run alone for packages that do put things there that should be in /var/lib
    mount the VFS as UnionFS allowing normal write to /var/run
    use Copy on Write for overwrites, store in /var/run.new
    as /var/run should get cleaned on proper shutdown,
    on boot before setup of the VFS move anything remaining into /var/run.old
    (optional, but could be useful after a crash or compromise).

    Just a thought.
    -Z

  3. cjk

    Quote your shell words.