mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
services: base: Add optional delayed mount of file-systems
Add a mechanism to only require mounting a subset of file-system entries during early Shepherd initialization. Any file-system with additional Shepherd service requirements (e.g. networking) is not required to provision 'file-systems. * gnu/services/base.scm (file-system-shepherd-service): Splice file-system-requirements into the Shepherd service requirement list. (file-system-shepherd-services): Provision 'file-system only when file system services without additional Shepherd requirements are started. * gnu/system/file-systems.scm (file-system): Add shepherd-requirements field to the file-system record. This field is used for adding additional Shepherd requirements to a file-system Shepherd service. * doc/guix.texi: Add documentation for file-system shepherd-requirements. Change-Id: If0392db03d48e8820aa53df1df482c12ec72e1a5 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
5d3edff1a6
commit
579df5bc80
3 changed files with 56 additions and 29 deletions
|
@ -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
|
Another example is a file system that depends on a mapped device, for
|
||||||
example for an encrypted partition (@pxref{Mapped Devices}).
|
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 table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
|
@ -404,6 +404,7 @@ (define (file-system-shepherd-service file-system)
|
||||||
(create? (file-system-create-mount-point? file-system))
|
(create? (file-system-create-mount-point? file-system))
|
||||||
(mount? (file-system-mount? file-system))
|
(mount? (file-system-mount? file-system))
|
||||||
(dependencies (file-system-dependencies file-system))
|
(dependencies (file-system-dependencies file-system))
|
||||||
|
(requirements (file-system-shepherd-requirements file-system))
|
||||||
(packages (file-system-packages (list file-system))))
|
(packages (file-system-packages (list file-system))))
|
||||||
(and (or mount? create?)
|
(and (or mount? create?)
|
||||||
(with-imported-modules (source-module-closure
|
(with-imported-modules (source-module-closure
|
||||||
|
@ -412,7 +413,8 @@ (define (file-system-shepherd-service file-system)
|
||||||
(provision (list (file-system->shepherd-service-name file-system)))
|
(provision (list (file-system->shepherd-service-name file-system)))
|
||||||
(requirement `(root-file-system
|
(requirement `(root-file-system
|
||||||
udev
|
udev
|
||||||
,@(map dependency->shepherd-service-name dependencies)))
|
,@(map dependency->shepherd-service-name dependencies)
|
||||||
|
,@requirements))
|
||||||
(documentation "Check, mount, and unmount the given file system.")
|
(documentation "Check, mount, and unmount the given file system.")
|
||||||
(start #~(lambda args
|
(start #~(lambda args
|
||||||
#$(if create?
|
#$(if create?
|
||||||
|
@ -461,12 +463,20 @@ (define (file-system-shepherd-services file-systems)
|
||||||
(or (file-system-mount? x)
|
(or (file-system-mount? x)
|
||||||
(file-system-create-mount-point? x)))
|
(file-system-create-mount-point? x)))
|
||||||
file-systems)))
|
file-systems)))
|
||||||
|
|
||||||
(define sink
|
(define sink
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
(provision '(file-systems))
|
(provision '(file-systems))
|
||||||
(requirement (cons* 'root-file-system 'user-file-systems
|
(requirement (cons* 'root-file-system 'user-file-systems
|
||||||
(map file-system->shepherd-service-name
|
(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")
|
(documentation "Target for all the initially-mounted file systems")
|
||||||
(start #~(const #t))
|
(start #~(const #t))
|
||||||
(stop #~(const #f))))
|
(stop #~(const #f))))
|
||||||
|
|
|
@ -57,6 +57,7 @@ (define-module (gnu system file-systems)
|
||||||
file-system-repair
|
file-system-repair
|
||||||
file-system-create-mount-point?
|
file-system-create-mount-point?
|
||||||
file-system-dependencies
|
file-system-dependencies
|
||||||
|
file-system-shepherd-requirements
|
||||||
file-system-location
|
file-system-location
|
||||||
|
|
||||||
file-system-type-predicate
|
file-system-type-predicate
|
||||||
|
@ -161,33 +162,35 @@ (define-syntax validate-file-system-flags
|
||||||
(define-record-type* <file-system> file-system
|
(define-record-type* <file-system> file-system
|
||||||
make-file-system
|
make-file-system
|
||||||
file-system?
|
file-system?
|
||||||
(device file-system-device) ; string | <uuid> | <file-system-label>
|
(device file-system-device) ; string | <uuid> | <file-system-label>
|
||||||
(mount-point file-system-mount-point) ; string
|
(mount-point file-system-mount-point) ; string
|
||||||
(type file-system-type) ; string
|
(type file-system-type) ; string
|
||||||
(flags file-system-flags ; list of symbols
|
(flags file-system-flags ; list of symbols
|
||||||
(default '())
|
(default '())
|
||||||
(sanitize validate-file-system-flags))
|
(sanitize validate-file-system-flags))
|
||||||
(options file-system-options ; string or #f
|
(options file-system-options ; string or #f
|
||||||
(default #f))
|
(default #f))
|
||||||
(mount? file-system-mount? ; Boolean
|
(mount? file-system-mount? ; Boolean
|
||||||
(default #t))
|
(default #t))
|
||||||
(mount-may-fail? file-system-mount-may-fail? ; Boolean
|
(mount-may-fail? file-system-mount-may-fail? ; Boolean
|
||||||
(default #f))
|
(default #f))
|
||||||
(needed-for-boot? %file-system-needed-for-boot? ; Boolean
|
(needed-for-boot? %file-system-needed-for-boot? ; Boolean
|
||||||
(default #f))
|
(default #f))
|
||||||
(check? file-system-check? ; Boolean
|
(check? file-system-check? ; Boolean
|
||||||
(default #t))
|
(default #t))
|
||||||
(skip-check-if-clean? file-system-skip-check-if-clean? ; Boolean
|
(skip-check-if-clean? file-system-skip-check-if-clean? ; Boolean
|
||||||
(default #t))
|
(default #t))
|
||||||
(repair file-system-repair ; symbol or #f
|
(repair file-system-repair ; symbol or #f
|
||||||
(default 'preen))
|
(default 'preen))
|
||||||
(create-mount-point? file-system-create-mount-point? ; Boolean
|
(create-mount-point? file-system-create-mount-point? ; Boolean
|
||||||
(default #f))
|
(default #f))
|
||||||
(dependencies file-system-dependencies ; list of <file-system>
|
(dependencies file-system-dependencies ; list of <file-system>
|
||||||
(default '())) ; or <mapped-device>
|
(default '())) ; or <mapped-device>
|
||||||
(location file-system-location
|
(shepherd-requirements file-system-shepherd-requirements ; list of symbols
|
||||||
(default (current-source-location))
|
(default '()))
|
||||||
(innate)))
|
(location file-system-location
|
||||||
|
(default (current-source-location))
|
||||||
|
(innate)))
|
||||||
|
|
||||||
;; A file system label for use in the 'device' field.
|
;; A file system label for use in the 'device' field.
|
||||||
(define-record-type <file-system-label>
|
(define-record-type <file-system-label>
|
||||||
|
|
Loading…
Reference in a new issue