diff --git a/doc/guix.texi b/doc/guix.texi index 8cc01b2e65..9b60e6c603 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17862,6 +17862,20 @@ a dependency of @file{/sys/fs/cgroup/cpu} and Another example is a file system that depends on a mapped device, for example for an encrypted partition (@pxref{Mapped Devices}). + +@item @code{shepherd-requirements} (default: @code{'()}) +This is a list of symbols denoting Shepherd requirements that must be +met before mounting the file system. + +As an example, an NFS file system would typically have a requirement for +@code{networking}. + +Typically, file systems are mounted before most other Shepherd services +are started. However, file systems with a non-empty +shepherd-requirements field are mounted after Shepherd services have +begun. Any Shepherd service that depends on a file system with a +non-empty shepherd-requirements field must depend on it directly and not +on the generic symbol @code{file-systems}. @end table @end deftp diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 5f69b68f79..2d6b0f00e0 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -404,6 +404,7 @@ upon boot." (create? (file-system-create-mount-point? file-system)) (mount? (file-system-mount? file-system)) (dependencies (file-system-dependencies file-system)) + (requirements (file-system-shepherd-requirements file-system)) (packages (file-system-packages (list file-system)))) (and (or mount? create?) (with-imported-modules (source-module-closure @@ -412,7 +413,8 @@ upon boot." (provision (list (file-system->shepherd-service-name file-system))) (requirement `(root-file-system udev - ,@(map dependency->shepherd-service-name dependencies))) + ,@(map dependency->shepherd-service-name dependencies) + ,@requirements)) (documentation "Check, mount, and unmount the given file system.") (start #~(lambda args #$(if create? @@ -461,12 +463,20 @@ upon boot." (or (file-system-mount? x) (file-system-create-mount-point? x))) file-systems))) + (define sink (shepherd-service (provision '(file-systems)) (requirement (cons* 'root-file-system 'user-file-systems (map file-system->shepherd-service-name - file-systems))) + ;; Do not require file systems with Shepherd + ;; requirements to provision + ;; 'file-systems. Many Shepherd services + ;; require 'file-systems, so we would likely + ;; deadlock. + (filter (lambda (file-system) + (null? (file-system-shepherd-requirements file-system))) + file-systems)))) (documentation "Target for all the initially-mounted file systems") (start #~(const #t)) (stop #~(const #f)))) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index c791b24a9f..4ea8237c70 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -57,6 +57,7 @@ file-system-repair file-system-create-mount-point? file-system-dependencies + file-system-shepherd-requirements file-system-location file-system-type-predicate @@ -161,33 +162,35 @@ flags are found." (define-record-type* file-system make-file-system file-system? - (device file-system-device) ; string | | - (mount-point file-system-mount-point) ; string - (type file-system-type) ; string - (flags file-system-flags ; list of symbols - (default '()) - (sanitize validate-file-system-flags)) - (options file-system-options ; string or #f - (default #f)) - (mount? file-system-mount? ; Boolean - (default #t)) - (mount-may-fail? file-system-mount-may-fail? ; Boolean - (default #f)) - (needed-for-boot? %file-system-needed-for-boot? ; Boolean - (default #f)) - (check? file-system-check? ; Boolean - (default #t)) - (skip-check-if-clean? file-system-skip-check-if-clean? ; Boolean - (default #t)) - (repair file-system-repair ; symbol or #f - (default 'preen)) - (create-mount-point? file-system-create-mount-point? ; Boolean - (default #f)) - (dependencies file-system-dependencies ; list of - (default '())) ; or - (location file-system-location - (default (current-source-location)) - (innate))) + (device file-system-device) ; string | | + (mount-point file-system-mount-point) ; string + (type file-system-type) ; string + (flags file-system-flags ; list of symbols + (default '()) + (sanitize validate-file-system-flags)) + (options file-system-options ; string or #f + (default #f)) + (mount? file-system-mount? ; Boolean + (default #t)) + (mount-may-fail? file-system-mount-may-fail? ; Boolean + (default #f)) + (needed-for-boot? %file-system-needed-for-boot? ; Boolean + (default #f)) + (check? file-system-check? ; Boolean + (default #t)) + (skip-check-if-clean? file-system-skip-check-if-clean? ; Boolean + (default #t)) + (repair file-system-repair ; symbol or #f + (default 'preen)) + (create-mount-point? file-system-create-mount-point? ; Boolean + (default #f)) + (dependencies file-system-dependencies ; list of + (default '())) ; or + (shepherd-requirements file-system-shepherd-requirements ; list of symbols + (default '())) + (location file-system-location + (default (current-source-location)) + (innate))) ;; A file system label for use in the 'device' field. (define-record-type