guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/04: vm: Support creating FAT partitions.


From: Marius Bakke
Subject: 02/04: vm: Support creating FAT partitions.
Date: Fri, 19 May 2017 12:15:13 -0400 (EDT)

mbakke pushed a commit to branch master
in repository guix.

commit 4d415f0c3c0cf4acbc1297ccf2b27121846a4289
Author: Marius Bakke <address@hidden>
Date:   Sat May 6 22:53:58 2017 +0200

    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.
---
 gnu/build/vm.scm            | 30 ++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +---
 gnu/system/vm.scm           |  2 +-
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index c7449cf..7ce1ec8 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -213,10 +213,10 @@ actual /dev name based on DEVICE."
 
 (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 @@ volume name."
                             '())))
     (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."
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index dfe198e..3a5e760 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -268,6 +268,7 @@ loaded at boot time in the order in which they appear."
       "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 @@ loaded at boot time in the order in which they appear."
       ,@(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")
             '())
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index e0e4d33..64770ba 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -203,7 +203,7 @@ the image."
                       (guix build utils))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs)
+                '#$(append (list qemu parted e2fsprogs dosfstools)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]