[bug#73494,v3,1/3] file-systems: %base-file-systems: Add tmpfs /run.

Message ID ea0b0f0bf20bbfec9a71c805ddf2a348a056479b.1741241800.git.hako@ultrarare.space
State New
Headers
Series tmpfs /run |

Commit Message

Hilton Chain March 6, 2025, 6:22 a.m. UTC
  * gnu/system/file-systems (%runtime-variable-data): New variable.
(%base-file-systems): Add it.
* doc/guix.texi (File Systems): Document it.
* gnu/services.scm (cleanup-gexp): Adjust accordingly.

Change-Id: I3a95e49d396fbb2577026aefc247cfe996c5f267
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 doc/guix.texi               |  5 +++++
 gnu/services.scm            |  5 +----
 gnu/system/file-systems.scm | 17 ++++++++++++++++-
 3 files changed, 22 insertions(+), 5 deletions(-)
  

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 6844470ce2..70e5db4156 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18228,6 +18228,11 @@  File Systems
 read-write in its own ``name space.''
 @end defvar
 
+@defvar %runtime-variable-data
+This file system is mounted as @file{/run} and contains system
+information data describing the system since it was booted.
+@end defvar
+
 @defvar %binary-format-file-system
 The @code{binfmt_misc} file system, which allows handling of arbitrary
 executable file types to be delegated to user space.  This requires the
diff --git a/gnu/services.scm b/gnu/services.scm
index 8a4002e072..ea855ad193 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -632,7 +632,7 @@  (define (cleanup-gexp _)
     #~(begin
         (use-modules (guix build utils))
 
-        ;; Clean out /tmp, /var/run, and /run.
+        ;; Clean out /tmp and /var/run.
         ;;
         ;; XXX This needs to happen before service activations, so it
         ;; has to be here, but this also implicitly assumes that /tmp
@@ -663,15 +663,12 @@  (define (cleanup-gexp _)
            (setlocale LC_CTYPE "en_US.utf8")
            (delete-file-recursively "/tmp")
            (delete-file-recursively "/var/run")
-           (delete-file-recursively "/run")
 
            ;; Note: The second argument to 'mkdir' is and'ed with umask,
            ;; hence the 'chmod' calls.
            (mkdir "/tmp" #o1777)
            (chmod "/tmp" #o1777)
            (mkdir "/var/run" #o755)
-           (chmod "/var/run" #o755)
-           (mkdir "/run" #o755)
            (chmod "/var/run" #o755))))))
 
 (define cleanup-service-type
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index 4ea8237c70..b2766707a3 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -82,6 +82,7 @@  (define-module (gnu system file-systems)
             %pseudo-terminal-file-system
             %tty-gid
             %immutable-store
+            %runtime-variable-data
             %control-groups
             %elogind-file-systems
 
@@ -448,6 +449,19 @@  (define %immutable-store
     (check? #f)
     (flags '(read-only bind-mount no-atime))))
 
+(define %runtime-variable-data
+  (file-system
+    (type "tmpfs")
+    (mount-point "/run")
+    (device "tmpfs")
+    ;; Don't use no-suid here as /run/privileged/bin may contain SUID
+    ;; executables.
+    (flags '(no-dev strict-atime))
+    (options "mode=0755,nr_inodes=800k,size=20%")
+    (needed-for-boot? #t)
+    (check? #f)
+    (create-mount-point? #t)))
+
 (define %control-groups
   ;; The cgroup2 file system.
   (list (file-system
@@ -497,7 +511,8 @@  (define %base-file-systems
         %debug-file-system
         %shared-memory-file-system
         %efivars-file-system
-        %immutable-store))
+        %immutable-store
+        %runtime-variable-data))
 
 (define %base-live-file-systems
   ;; This is the bare minimum to use live file-systems.