guix: system: Make disk-image root file system non-volatile by default.

And add a new '--volatile' option to have it volatile otherwise.

* guix/scripts/system.scm (%options)[volatile-root?]: New boolean option.
(%default-options): Set its default value to #f.
(show-help): Add help doc.
* guix/scripts/system.scm (perform-action): Propagate option...
(system-derivation-for-action): ...here.  Use it to set the volatile-root?
field of the image object passed to SYSTEM-IMAGE.
* doc/guix.texi (Invoking guix system): Document it.
This commit is contained in:
Maxim Cournoyer 2020-11-11 23:48:12 -05:00
parent ac96f2c836
commit 41f27bf870
No known key found for this signature in database
GPG key ID: 1260E46482E63562
2 changed files with 21 additions and 6 deletions

View file

@ -31029,10 +31029,12 @@ the @option{--image-size} option is ignored in the case of
@cindex disk-image, creating disk images
The @code{disk-image} command can produce various image types. The
image type can be selected using the @command{--image-type} option. It
image type can be selected using the @option{--image-type} option. It
defaults to @code{raw}. When its value is @code{iso9660}, the
@option{--label} option can be used to specify a volume ID with
@code{disk-image}. When using @code{disk-image}, the bootloader
@code{disk-image}. By default, the root file system of a disk image is
mounted non-volatile; the @option{--volatile} option can be provided to
make it volatile instead. When using @code{disk-image}, the bootloader
installed on the generated image is taken from the provided
@code{operating-system} definition. The following example demonstrates
how to generate an image that uses the @code{grub-efi-bootloader}

View file

@ -674,7 +674,8 @@ (define file-systems
(define* (system-derivation-for-action os action
#:key image-size image-type
full-boot? container-shared-network?
mappings label)
mappings label
volatile-root?)
"Return as a monadic value the derivation for OS according to ACTION."
(mlet %store-monad ((target (current-target-system)))
(case action
@ -706,7 +707,8 @@ (define* (system-derivation-for-action os action
base-image))
(target (or base-target target))
(size image-size)
(operating-system os))))))
(operating-system os)
(volatile-root? volatile-root?))))))
((docker-image)
(system-docker-image os
#:shared-network? container-shared-network?)))))
@ -761,6 +763,7 @@ (define* (perform-action action os
dry-run? derivations-only?
use-substitutes? bootloader-target target
image-size image-type
volatile-root?
full-boot? label container-shared-network?
(mappings '())
(gc-root #f))
@ -768,7 +771,8 @@ (define* (perform-action action os
bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the
target root directory; IMAGE-SIZE is the size of the image to be built, for
the 'vm-image' and 'disk-image' actions. IMAGE-TYPE is the type of image to
be built.
be built. When VOLATILE-ROOT? is #t, the root file system is mounted
volatile.
FULL-BOOT? is used for the 'vm' action; it determines whether to
boot directly to the kernel or to the bootloader. CONTAINER-SHARED-NETWORK?
@ -816,6 +820,7 @@ (define bootcfg
#:label label
#:image-type image-type
#:image-size image-size
#:volatile-root? volatile-root?
#:full-boot? full-boot?
#:container-shared-network? container-shared-network?
#:mappings mappings))
@ -974,6 +979,8 @@ (define (show-help)
--image-size=SIZE for 'vm-image', produce an image of SIZE"))
(display (G_ "
--no-bootloader for 'init', do not install a bootloader"))
(display (G_ "
--volatile for 'disk-image', make the root file system volatile"))
(display (G_ "
--label=LABEL for 'disk-image', label disk image with LABEL"))
(display (G_ "
@ -1048,6 +1055,9 @@ (define %options
(option '("no-bootloader" "no-grub") #f #f
(lambda (opt name arg result)
(alist-cons 'install-bootloader? #f result)))
(option '("volatile") #f #f
(lambda (opt name arg result)
(alist-cons 'volatile-root? #t result)))
(option '("label") #t #f
(lambda (opt name arg result)
(alist-cons 'label arg result)))
@ -1109,7 +1119,8 @@ (define %default-options
(image-type . raw)
(image-size . guess)
(install-bootloader? . #t)
(label . #f)))
(label . #f)
(volatile-root? . #f)))
(define (verbosity-level opts)
"Return the verbosity level based on OPTS, the alist of parsed options."
@ -1206,6 +1217,8 @@ (define save-provenance?
#:image-type (lookup-image-type-by-name
(assoc-ref opts 'image-type))
#:image-size (assoc-ref opts 'image-size)
#:volatile-root?
(assoc-ref opts 'volatile-root?)
#:full-boot? (assoc-ref opts 'full-boot?)
#:container-shared-network?
(assoc-ref opts 'container-shared-network?)