109

I just ran df -h a minute ago and noticed a filesystem has been added that I'm not familiar with. Does anyone know why /run exists? Is this something that's been added by the kernel? By Arch Linux?

run              10M  236K  9.8M   3% /run
Mat
  • 52,586
xenoterracide
  • 59,188
  • 74
  • 187
  • 252
  • 7
    Related: See the Debian /run release goal document, which includes details about how the change applies to 7.0+. http://wiki.debian.org/ReleaseGoals/RunDirectory – Zoredache May 28 '13 at 23:15
  • See here: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html – dr_ Sep 23 '19 at 07:22

2 Answers2

72

Apparently, many tools (among them udev) will soon require a /run/ directory that is mounted early (as tmpfs). Arch developers introduced /run last month to prepare for this.

The udev runtime data moved from /dev/.udev/ to /run/udev/. The /run mountpoint is supposed to be a tmpfs mounted during early boot, available and writable to for all tools at any time during bootup, it replaces /var/run/, which should become a symlink some day. [1]

There is more detail here: http://www.h-online.com/open/news/item/Linux-distributions-to-include-run-directory-1219006.html

[1] From thread on the Arch Projects ML

jasonwryan
  • 73,126
  • 2
    is it only for Arch or what ? /run will be add in RHEL/CentOs, Ubuntu ? – Rahul Patil Apr 07 '13 at 18:59
  • 3
    Do files get automatically deleted when the process stops running? – Ian Ringrose Dec 08 '16 at 09:49
  • 2
    @Ian, if it's a tmpfs filesystem, then on reboot it will be emptied. Your question: as I know, files would not be automatically deleted, rather process itself has to do proper cleanup. –  Feb 05 '17 at 05:49
  • @BulatM. tmpfs is explicitly RAM-backed (it will swap though if not all fits in RAM), so on power off everything in /run is lost by design, and no process has to go and clean up previous files. – joonas.fi Sep 12 '21 at 09:15
53

The /run directory is the companion directory to /var/run. Like for example /bin is the companion of /usr/bin.

That means that daemons like systemd and udev, which are started very early in the boot process - and perhaps before /var/run is available (i.e. mounted) - have with /run a standardized file system location available where they can store runtime information.

Like /bin contains important programs, which may be needed in the boot process before /usr is available (in case it is on its own filesystem).

The /run idea is a relatively new idea/standard.

maxschlepzig
  • 57,532
  • 3
    Arch's /var/run directory is symlinked to /run. –  Apr 20 '13 at 22:24
  • 3
    Debian's /var/run is also symlinked to /run – naoko Jan 16 '16 at 14:04
  • 2
    So is Ubuntu 16.10's. – Federico Poloni Mar 27 '17 at 18:01
  • 7
    This answer is misleading. /run exists because /var/run was the wrong location, and most distros either symlink or bind mount them to each other. They are not intended to be separate directories; /run is the correct location, /var/run is kept around to support legacy software. See https://lwn.net/Articles/436012/ for the motivation behind it. – Matthew Sharp Dec 24 '20 at 04:48
  • @MatthewSharp your comment is misleading. Did you even read the link you posted? – maxschlepzig Dec 25 '20 at 16:22
  • 2
    @maxschlepzig Yes I did. My comment was probably a bit non-specific, but it would help if you were more specific about what is misleading in my comment. – Matthew Sharp Dec 26 '20 at 19:25