guix system: Add 'disk-image' action.
* guix/scripts/system.scm (show-help): Add 'disk-image'. (guix-system)[parse-options]: Support 'disk-image' action. [option-arguments]: Likewise. Handle the 'disk-image' action. * doc/guix.texi (Invoking guix system): Document 'disk-image'.
This commit is contained in:
parent
1e77fedb46
commit
fb729425dc
2 changed files with 26 additions and 6 deletions
|
|
@ -3236,9 +3236,23 @@ Build a virtual machine that contain the operating system declared in
|
||||||
The VM shares its store with the host system.
|
The VM shares its store with the host system.
|
||||||
|
|
||||||
@item vm-image
|
@item vm-image
|
||||||
Return a virtual machine image of the operating system declared in
|
@itemx disk-image
|
||||||
@var{file} that stands alone. Use the @option{--image-size} option to
|
Return a virtual machine or disk image of the operating system declared
|
||||||
specify the size of the image.
|
in @var{file} that stands alone. Use the @option{--image-size} option
|
||||||
|
to specify the size of the image.
|
||||||
|
|
||||||
|
When using @code{vm-image}, the returned image is in qcow2 format, which
|
||||||
|
the QEMU emulator can efficiently use.
|
||||||
|
|
||||||
|
When using @code{disk-image}, a raw disk image is produced; it can be
|
||||||
|
copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
|
||||||
|
the device corresponding to a USB stick, one can copy the image on it
|
||||||
|
using the following command:
|
||||||
|
|
||||||
|
@example
|
||||||
|
# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
|
||||||
|
@end example
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@var{options} can contain any of the common build options provided by
|
@var{options} can contain any of the common build options provided by
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
|
||||||
(display (_ "\
|
(display (_ "\
|
||||||
- 'vm-image', build a freestanding virtual machine image\n"))
|
- 'vm-image', build a freestanding virtual machine image\n"))
|
||||||
(display (_ "\
|
(display (_ "\
|
||||||
|
- 'disk-image', build a disk image, suitable for a USB stick\n"))
|
||||||
|
(display (_ "\
|
||||||
- 'init', initialize a root file system to run GNU.\n"))
|
- 'init', initialize a root file system to run GNU.\n"))
|
||||||
|
|
||||||
(show-build-options-help)
|
(show-build-options-help)
|
||||||
|
|
@ -191,7 +193,7 @@ Build the operating system declared in FILE according to ACTION.\n"))
|
||||||
(alist-cons 'argument arg result)
|
(alist-cons 'argument arg result)
|
||||||
(let ((action (string->symbol arg)))
|
(let ((action (string->symbol arg)))
|
||||||
(case action
|
(case action
|
||||||
((build vm vm-image init)
|
((build vm vm-image disk-image init)
|
||||||
(alist-cons 'action action result))
|
(alist-cons 'action action result))
|
||||||
(else (leave (_ "~a: unknown action~%")
|
(else (leave (_ "~a: unknown action~%")
|
||||||
action))))))
|
action))))))
|
||||||
|
|
@ -214,7 +216,7 @@ Build the operating system declared in FILE according to ACTION.\n"))
|
||||||
action))
|
action))
|
||||||
|
|
||||||
(case action
|
(case action
|
||||||
((build vm vm-image)
|
((build vm vm-image disk-image)
|
||||||
(unless (= count 1)
|
(unless (= count 1)
|
||||||
(fail)))
|
(fail)))
|
||||||
((init)
|
((init)
|
||||||
|
|
@ -238,7 +240,11 @@ Build the operating system declared in FILE according to ACTION.\n"))
|
||||||
(system-qemu-image os
|
(system-qemu-image os
|
||||||
#:disk-image-size size)))
|
#:disk-image-size size)))
|
||||||
((vm)
|
((vm)
|
||||||
(system-qemu-image/shared-store-script os))))
|
(system-qemu-image/shared-store-script os))
|
||||||
|
((disk-image)
|
||||||
|
(let ((size (assoc-ref opts 'image-size)))
|
||||||
|
(system-disk-image os
|
||||||
|
#:disk-image-size size)))))
|
||||||
(store (open-connection))
|
(store (open-connection))
|
||||||
(dry? (assoc-ref opts 'dry-run?))
|
(dry? (assoc-ref opts 'dry-run?))
|
||||||
(drv (run-with-store store mdrv))
|
(drv (run-with-store store mdrv))
|
||||||
|
|
|
||||||
Reference in a new issue