Difference between /run and /var/run

41,427

Solution 1

From the Wikipedia page on the Filesystem Hierarchy Standard:

Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs) which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, this data should be stored in /var/run but this was a problem in some cases because this directory isn't always available at early boot. As a result, these programs have had to resort to trickery, such as using /dev/.udev, /dev/.mdadm, /dev/.systemd or /dev/.mount directories, even though the device directory isn't intended for such data. Among other advantages, this makes the system easier to use normally with the root filesystem mounted read-only.

So if you have already made a temporary filesystem for /run, linking /var/run to it would be the next logical step (as opposed to keeping the files on disk or creating a separate tmpfs).

Solution 2

Some utilities traditionally used /var/run, other /run to store their process related material. When these were real on disc directories it did not matter too much that these were separate directories.

Nowadays /run/ is often implemented as a tmpfs ( mount | fgrep run ) and data in those directories won't survive a reboot (which is a good thing). It makes a little more sense to map these together using a symbolic link, and save a mount, especially as the permissions and settings for these directories would be the same anyway (in contrast to some other "directories" that are on tmpfs )

Share:
41,427

Related videos on Youtube

Jackzz
Author by

Jackzz

A simple software developer working with C++..

Updated on September 18, 2022

Comments

  • Jackzz
    Jackzz over 1 year

    Is there any difference between /run directory and var/run directory. It seems the latter is a link to the former. If the contents are one and the same what is the need for two directories?

  • x-yuri
    x-yuri about 5 years
    To make it clear, /run is new /var/run. So, /var/run is generally symlinked to /run.