system: Add a 'needed-for-boot?' field to 'mapped-device'.

* gnu/system/file-systems.scm (<mapped-device>)[needed-for-boot?]: New
  field.
* gnu/system.scm (operating-system-user-mapped-devices,
  operating-system-boot-mapped-devices): Use it instead of trying to
  guess.  Guessing doesn't work when one refers to a partition using its
  label, for instance.
* doc/guix.texi (Mapped Devices): Document 'needed-for-boot?'.
This commit is contained in:
Ludovic Courtès 2014-11-29 14:40:26 +01:00
parent 9cd0dfaa46
commit 3b09332adf
3 changed files with 20 additions and 18 deletions

View file

@ -3837,19 +3837,27 @@ detailed below.
Objects of this type represent device mappings that will be made when Objects of this type represent device mappings that will be made when
the system boots up. the system boots up.
@table @code @table @asis
@item source @item @code{source}
This string specifies the name of the block device to be mapped, such as This string specifies the name of the block device to be mapped, such as
@code{"/dev/sda3"}. @code{"/dev/sda3"}.
@item target @item @code{target}
This string specifies the name of the mapping to be established. For This string specifies the name of the mapping to be established. For
example, specifying @code{"my-partition"} will lead to the creation of example, specifying @code{"my-partition"} will lead to the creation of
the @code{"/dev/mapper/my-partition"} device. the @code{"/dev/mapper/my-partition"} device.
@item type @item @code{type}
This must be a @code{mapped-device-kind} object, which specifies how This must be a @code{mapped-device-kind} object, which specifies how
@var{source} is mapped to @var{target}. @var{source} is mapped to @var{target}.
@item @code{needed-for-boot?} (default: @code{#f})
This Boolean value indicates whether the device mapping must be made at
boot time---i.e., from the initial RAM disk, before any user file
systems are mounted.
You would set it to @code{#t} for instance when the mapped device is
used by the root file system.
@end table @end table
@end deftp @end deftp

View file

@ -250,23 +250,14 @@ (define (mapped-device-user device file-systems)
(define (operating-system-user-mapped-devices os) (define (operating-system-user-mapped-devices os)
"Return the subset of mapped devices that can be installed in "Return the subset of mapped devices that can be installed in
user-land--i.e., those not needed during boot." user-land--i.e., those not needed during boot."
(let ((devices (operating-system-mapped-devices os)) (remove mapped-device-needed-for-boot?
(file-systems (operating-system-file-systems os))) (operating-system-mapped-devices os)))
(filter (lambda (md)
(let ((user (mapped-device-user md file-systems)))
(or (not user)
(not (file-system-needed-for-boot? user)))))
devices)))
(define (operating-system-boot-mapped-devices os) (define (operating-system-boot-mapped-devices os)
"Return the subset of mapped devices that must be installed during boot, "Return the subset of mapped devices that must be installed during boot,
from the initrd." from the initrd."
(let ((devices (operating-system-mapped-devices os)) (filter mapped-device-needed-for-boot?
(file-systems (operating-system-file-systems os))) (operating-system-mapped-devices os)))
(filter (lambda (md)
(let ((user (mapped-device-user md file-systems)))
(and user (file-system-needed-for-boot? user))))
devices)))
(define (device-mapping-services os) (define (device-mapping-services os)
"Return the list of device-mapping services for OS as a monadic list." "Return the list of device-mapping services for OS as a monadic list."

View file

@ -45,6 +45,7 @@ (define-module (gnu system file-systems)
mapped-device-source mapped-device-source
mapped-device-target mapped-device-target
mapped-device-type mapped-device-type
mapped-device-needed-for-boot?
mapped-device-kind mapped-device-kind
mapped-device-kind? mapped-device-kind?
@ -157,7 +158,9 @@ (define-record-type* <mapped-device> mapped-device
mapped-device? mapped-device?
(source mapped-device-source) ;string (source mapped-device-source) ;string
(target mapped-device-target) ;string (target mapped-device-target) ;string
(type mapped-device-type)) ;<mapped-device-kind> (type mapped-device-type) ;<mapped-device-kind>
(needed-for-boot? mapped-device-needed-for-boot? ;Boolean
(default #f)))
(define-record-type* <mapped-device-type> mapped-device-kind (define-record-type* <mapped-device-type> mapped-device-kind
make-mapped-device-kind make-mapped-device-kind