guix-commits
[Top][All Lists]
Advanced

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

02/03: initrd: Honor rootfstype and rootflags command-line parameters.


From: guix-commits
Subject: 02/03: initrd: Honor rootfstype and rootflags command-line parameters.
Date: Fri, 18 Feb 2022 01:36:40 -0500 (EST)

apteryx pushed a commit to branch wip-initrd-rootflags
in repository guix.

commit eda2197acf45baeb871dd2a091ea895e8d2b45b9
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Fri Feb 18 00:09:05 2022 -0500

    initrd: Honor rootfstype and rootflags command-line parameters.
    
    * gnu/build/linux-boot.scm (boot-system): Honor rootfstype and rootflags
    arguments.  Update doc.  Error out in case there is insufficient information
    with regard to the root file system.  Restore the behavior of inferring the
    root device from the root file system from the operating system in case the
    root argument is not provided.
    * doc/guix.texi (Initial RAM Disk): Document the new command-line 
parameters.
---
 doc/guix.texi            | 10 +++++++++
 gnu/build/linux-boot.scm | 56 +++++++++++++++++++++++++++++++-----------------
 2 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 849ef227fc..91766dec8b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -34917,6 +34917,16 @@ name like @code{/dev/sda1}, a file system label, or a 
file system UUID.
 When unspecified, the device name from the root file system of the
 operating system declaration is used.
 
+@item rootfstype=@var{type}
+Set the type of the root file system.  It overrides the @code{type}
+field of the root file system specified via the @code{operating-system}
+declaration, if any.
+
+@item rootflags=@var{options}
+Set the mount @emph{options} of the root file system.  It overrides the
+@code{options} field of the root file system specified via the
+@code{operating-system} declaration, if any.
+
 @item fsck.mode=@var{mode}
 Whether to check the @var{root} file system for errors before mounting
 it.  @var{mode} is one of @code{skip} (never check), @code{force} (always
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index d36601d824..dd98907195 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -501,7 +501,7 @@ QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting 
the file systems
 specified in MOUNTS, and finally booting into the new root if any.  The initrd
 supports kernel command-line options '--load' and '--repl'.  It also honors a
 subset of the Linux kernel command-line parameters such as 'fsck.mode',
-'resume', 'root' and 'rootdelay'.
+'resume', 'root', 'rootdelay', rootflags and rootfstype.
 
 Mount the root file system, specified by the 'root' command-line argument, if
 any.
@@ -533,17 +533,32 @@ upon error."
       (mount-essential-file-systems)
       (let* ((args    (linux-command-line))
              (to-load (find-long-option "--load" args))
-             ;; If present, ‘root’ on the kernel command line takes precedence
-             ;; over the ‘device’ field of the root <file-system> record.
              (root-device (and=> (find-long-option "root" args)
                                  device-string->file-system-device))
-             (root-fs (or (find root-mount-point? mounts)
-                          ;; Fall back to fictitious defaults.
-                          (file-system (device (or root-device "/dev/root"))
-                                       (mount-point "/")
-                                       (type "ext4"))))
+             (rootfstype  (find-long-option "rootfstype" args))
+             (rootflags   (find-long-option "rootflags" args))
+             (root-fs*    (find root-mount-point? mounts))
              (fsck.mode (find-long-option "fsck.mode" args)))
 
+        (unless (or root-fs* (and root-device rootfstype))
+          (error "no root file system or 'root' and 'rootfstype' parameters"))
+
+        ;; If present, ‘root’ on the kernel command line takes precedence over
+        ;; the ‘device’ field of the root <file-system> record; likewise for
+        ;; the 'rootfstype' and 'rootflags' arguments.
+        (define root-fs
+          (if root-fs*
+              (file-system
+                (inherit root-fs*)
+                (device (or root-device (file-system-device root-fs*)))
+                (type (or rootfstype (file-system-type root-fs*)))
+                (options (or rootflags (file-system-options root-fs*))))
+              (file-system
+                (device root-device)
+                (mount-point "/")
+                (type rootfstype)
+                (options rootflags))))
+
         (define (check? fs)
           (match fsck.mode
             ("skip"  #f)
@@ -615,18 +630,19 @@ the root file system...\n" root-delay)
 
         (setenv "EXT2FS_NO_MTAB_OK" "1")
 
-        (if root-device
-            (mount-root-file-system (canonicalize-device-spec root-device)
-                                    (file-system-type root-fs)
-                                    #:volatile-root? volatile-root?
-                                    #:flags (mount-flags->bit-mask
-                                             (file-system-flags root-fs))
-                                    #:options (file-system-options root-fs)
-                                    #:check? (check? root-fs)
-                                    #:skip-check-if-clean?
-                                    (skip-check-if-clean? root-fs)
-                                    #:repair (repair root-fs))
-            (mount "none" "/root" "tmpfs"))
+        ;; Mount the root file system.
+        (mount-root-file-system (canonicalize-device-spec
+                                 (file-system-device root-fs))
+                                (file-system-type root-fs)
+                                #:volatile-root? volatile-root?
+                                #:flags (mount-flags->bit-mask
+                                         (file-system-flags root-fs))
+                                #:options (file-system-options root-fs)
+                                #:check? (check? root-fs)
+                                #:skip-check-if-clean?
+                                (skip-check-if-clean? root-fs)
+                                #:repair (repair root-fs))
+        (mount "none" "/root" "tmpfs")
 
         ;; Mount the specified non-root file systems.
         (for-each (lambda (fs)



reply via email to

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