Ubuntu – Difference between /run and /var/run

directory-structurelinuxtmpfsUbuntu

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?

Best Answer

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).