vm: Allow a volume name to be specified for the root partition.
* guix/build/vm.scm (format-partition): Add #:label parameter, and honor it. (initialize-hard-disk): Add #:file-system-label parameter, and pass it to 'format-partition'. * gnu/system/vm.scm (qemu-image): Add #:file-system-label parameter and pass it to 'initialize-hard-disk'.
This commit is contained in:
parent
ff0bf0aca5
commit
ef9fc40dda
|
@ -196,15 +196,17 @@ made available under the /xchg CIFS share."
|
||||||
(disk-image-size (* 100 (expt 2 20)))
|
(disk-image-size (* 100 (expt 2 20)))
|
||||||
(disk-image-format "qcow2")
|
(disk-image-format "qcow2")
|
||||||
(file-system-type "ext4")
|
(file-system-type "ext4")
|
||||||
|
file-system-label
|
||||||
grub-configuration
|
grub-configuration
|
||||||
(register-closures? #t)
|
(register-closures? #t)
|
||||||
(inputs '())
|
(inputs '())
|
||||||
copy-inputs?)
|
copy-inputs?)
|
||||||
"Return a bootable, stand-alone QEMU image of type DISK-IMAGE-FORMAT (e.g.,
|
"Return a bootable, stand-alone QEMU image of type DISK-IMAGE-FORMAT (e.g.,
|
||||||
'qcow2' or 'raw'), with a root partition of type FILE-SYSTEM-TYPE. The
|
'qcow2' or 'raw'), with a root partition of type FILE-SYSTEM-TYPE.
|
||||||
returned image is a full disk image, with a GRUB installation that uses
|
Optionally, FILE-SYSTEM-LABEL can be specified as the volume name for the root
|
||||||
GRUB-CONFIGURATION as its configuration file (GRUB-CONFIGURATION must be the
|
partition. The returned image is a full disk image, with a GRUB installation
|
||||||
name of a file in the VM.)
|
that uses GRUB-CONFIGURATION as its configuration file (GRUB-CONFIGURATION
|
||||||
|
must be the name of a file in the VM.)
|
||||||
|
|
||||||
INPUTS is a list of inputs (as for packages). When COPY-INPUTS? is true, copy
|
INPUTS is a list of inputs (as for packages). When COPY-INPUTS? is true, copy
|
||||||
all of INPUTS into the image being built. When REGISTER-CLOSURES? is true,
|
all of INPUTS into the image being built. When REGISTER-CLOSURES? is true,
|
||||||
|
@ -243,7 +245,8 @@ the image."
|
||||||
#:copy-closures? #$copy-inputs?
|
#:copy-closures? #$copy-inputs?
|
||||||
#:register-closures? #$register-closures?
|
#:register-closures? #$register-closures?
|
||||||
#:disk-image-size #$disk-image-size
|
#:disk-image-size #$disk-image-size
|
||||||
#:file-system-type #$file-system-type)
|
#:file-system-type #$file-system-type
|
||||||
|
#:file-system-label #$file-system-label)
|
||||||
(reboot))))
|
(reboot))))
|
||||||
#:system system
|
#:system system
|
||||||
#:make-disk-image? #t
|
#:make-disk-image? #t
|
||||||
|
|
|
@ -158,10 +158,16 @@ REFERENCE-GRAPHS, a list of reference-graph files."
|
||||||
|
|
||||||
(define MS_BIND 4096) ; <sys/mounts.h> again!
|
(define MS_BIND 4096) ; <sys/mounts.h> again!
|
||||||
|
|
||||||
(define (format-partition partition type)
|
(define* (format-partition partition type
|
||||||
"Create a file system TYPE on PARTITION."
|
#:key label)
|
||||||
|
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
|
||||||
|
volume name."
|
||||||
(format #t "creating ~a partition...\n" type)
|
(format #t "creating ~a partition...\n" type)
|
||||||
(unless (zero? (system* (string-append "mkfs." type) "-F" partition))
|
(unless (zero? (apply system* (string-append "mkfs." type)
|
||||||
|
"-F" partition
|
||||||
|
(if label
|
||||||
|
`("-L" ,label)
|
||||||
|
'())))
|
||||||
(error "failed to create partition")))
|
(error "failed to create partition")))
|
||||||
|
|
||||||
(define* (initialize-root-partition target-directory
|
(define* (initialize-root-partition target-directory
|
||||||
|
@ -204,13 +210,15 @@ REFERENCE-GRAPHS, a list of reference-graph files."
|
||||||
grub.cfg
|
grub.cfg
|
||||||
disk-image-size
|
disk-image-size
|
||||||
(file-system-type "ext4")
|
(file-system-type "ext4")
|
||||||
|
file-system-label
|
||||||
(closures '())
|
(closures '())
|
||||||
copy-closures?
|
copy-closures?
|
||||||
(register-closures? #t))
|
(register-closures? #t))
|
||||||
"Initialize DEVICE, a disk of DISK-IMAGE-SIZE bytes, with a
|
"Initialize DEVICE, a disk of DISK-IMAGE-SIZE bytes, with a FILE-SYSTEM-TYPE
|
||||||
FILE-SYSTEM-TYPE partition, and with GRUB installed. If REGISTER-CLOSURES? is
|
partition with (optionally) FILE-SYSTEM-LABEL as its volume name, and with
|
||||||
true, register all of CLOSURES is the partition's store. If COPY-CLOSURES? is
|
GRUB installed. If REGISTER-CLOSURES? is true, register all of CLOSURES is
|
||||||
true, copy all of CLOSURES to the partition."
|
the partition's store. If COPY-CLOSURES? is true, copy all of CLOSURES to the
|
||||||
|
partition."
|
||||||
(define target-directory
|
(define target-directory
|
||||||
"/fs")
|
"/fs")
|
||||||
|
|
||||||
|
@ -220,7 +228,8 @@ true, copy all of CLOSURES to the partition."
|
||||||
(initialize-partition-table device
|
(initialize-partition-table device
|
||||||
(- disk-image-size (* 5 (expt 2 20))))
|
(- disk-image-size (* 5 (expt 2 20))))
|
||||||
|
|
||||||
(format-partition partition file-system-type)
|
(format-partition partition file-system-type
|
||||||
|
#:label file-system-label)
|
||||||
|
|
||||||
(display "mounting partition...\n")
|
(display "mounting partition...\n")
|
||||||
(mkdir target-directory)
|
(mkdir target-directory)
|
||||||
|
|
Loading…
Reference in New Issue