From the technical overview of Ubuntu 11.10 Oneiric:

Ubuntu 11.10 has migrated away from /var/run, /var/lock and /dev/shm and now uses /run, /run/lock and /run/shm instead (respectively).

  • I hardcode these paths in my applications, why is this change made to Oneiric?
  • What can I do to make my applications backwards- and forward-compatible? Is there a better way other than checking first for the existence of /run, and then /var/run?
link|improve this question

feedback

3 Answers

up vote 33 down vote accepted

The intent is to reduce the number of tmpfs file systems. On 11.04, there are separate tmpfs file systems at /var/lock, /var/run and /dev/shm. If these directories were all under a single parent directory, then only a single tmpfs would be needed. It also provides an obvious location for further runtime state data that shouldn't persist over reboots.

Unless your application depends on canonical paths of files, your application should run without modification since the old locations will be symlinked to the new ones. The AppArmor policies are one case that does depend on the real path names, which is why it was mentioned specifically.

The following links should help explain the rationale:

link|improve this answer
Thanks for your answer, those links are really useful. – Lekensteyn Aug 16 '11 at 10:21
feedback
  1. /run is a new cross-distribution tmpfs location for the storage of transient state files—that is, files containing run-time information that may or may not need to be written early in the boot process and which does not require preserving across reboots.

    Making the /run directory available brings us a step closer to the point where it is possible to use the system normally with the root filesystem mounted read-only, without requiring any clunky workarounds such as aufs/unionfs overlays.

    /run replaces several existing locations described in the Filesystem Hierarchy Standard:

    • /var/run/run
    • /var/lock/run/lock
    • /dev/shm/run/shm [currently only Debian plans to do this]
    • /tmp/run/tmp [optional; currently only Debian plans to offer this]
    • /run also replaces some other locations that have been used for transient files:

    • /lib/init/rw/run

    • /dev/.*/run/*
    • /dev/shm/*/run/*
    • writable files under /etc/run/*

    (so you probably can expect these to move aswell).

    Source:debian release goals

  2. I would advice on creating a part in your software where you set these directories in variables, change your code to use these variables and then alter the variables based on the system it is used on (but I bet you knew that already).

link|improve this answer
What do you mean writable files under /etc. Those must all persist past reboot, right? That's just generic conf files. – Evan Carroll Apr 24 at 16:43
Oh I see. Three files under /etc, /etc/lvm/cache/ /etc/mtab /etc/network/run/ifstate and soon /etc/adjtime. I suppose it was bad for them to be in /etc to begin with. – Evan Carroll Apr 24 at 16:45
feedback

From what I have read, this was the original explanation given as to why /run was introduced. http://lwn.net/Articles/436012/

link|improve this answer
3  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Stefano Palazzo Aug 16 '11 at 10:42
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.