vm: Support creating FAT partitions.

* gnu/build/vm.scm (create-ext-file-system, create-fat-file-system): New procedures.
(format-partition): Use them. Error for unknown file systems.
* gnu/system/vm.scm (qemu-image): Include DOSFSTOOLS.
* gnu/system/linux-initrd.scm (base-initrd): Always add nls_is8859-1.ko.
This commit is contained in:
Marius Bakke 2017-05-06 22:53:58 +02:00 committed by Ludovic Courtès
parent fd5a30ab7b
commit 03119da211
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 28 additions and 8 deletions

View file

@ -213,10 +213,10 @@ (define (options partitions offset)
(define MS_BIND 4096) ; <sys/mounts.h> again!
(define* (format-partition partition type
#:key label)
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
volume name."
(define* (create-ext-file-system partition type
#:key label)
"Create an ext-family filesystem of TYPE on PARTITION. If LABEL is true,
use that as the volume name."
(format #t "creating ~a partition...\n" type)
(unless (zero? (apply system* (string-append "mkfs." type)
"-F" partition
@ -225,6 +225,28 @@ (define* (format-partition partition type
'())))
(error "failed to create partition")))
(define* (create-fat-file-system partition
#:key label)
"Create a FAT filesystem on PARTITION. The number of File Allocation Tables
will be determined based on filesystem size. If LABEL is true, use that as the
volume name."
(format #t "creating FAT partition...\n")
(unless (zero? (apply system* "mkfs.fat" partition
(if label
`("-n" ,label)
'())))
(error "failed to create FAT partition")))
(define* (format-partition partition type
#:key label)
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
volume name."
(cond ((string-prefix? "ext" type)
(create-ext-file-system partition type #:label label))
((or (string-prefix? "fat" type) (string= "vfat" type))
(create-fat-file-system partition #:label label))
(else (error "Unsupported file system."))))
(define (initialize-partition partition)
"Format PARTITION, a <partition> object with a non-#f 'device' field, mount
it, run its initializer, and unmount it."

View file

@ -268,6 +268,7 @@ (define linux-modules
"usbhid" "hid-generic" "hid-apple" ;keyboards during early boot
"dm-crypt" "xts" "serpent_generic" "wp512" ;for encrypted root partitions
"nvme" ;for new SSD NVMe devices
"nls_iso8859-1" ;for `mkfs.fat`, et.al
,@(if (string-match "^(x86_64|i[3-6]86)-" (%current-system))
'("pata_acpi" "pata_atiixp" ;for ATA controllers
"isci") ;for SAS controllers like Intel C602
@ -281,9 +282,6 @@ (define linux-modules
,@(if (find (file-system-type-predicate "9p") file-systems)
virtio-9p-modules
'())
,@(if (find (file-system-type-predicate "vfat") file-systems)
'("nls_iso8859-1")
'())
,@(if (find (file-system-type-predicate "btrfs") file-systems)
'("btrfs")
'())

View file

@ -201,7 +201,7 @@ (define* (qemu-image #:key
(guix build utils))
(let ((inputs
'#$(append (list qemu parted grub e2fsprogs)
'#$(append (list qemu parted grub e2fsprogs dosfstools)
(map canonical-package
(list sed grep coreutils findutils gawk))
(if register-closures? (list guix) '())))