unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 40998@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#40998: [PATCH v2 3/4] initrd: Honor rootfstype and rootflags command-line parameters.
Date: Sat, 19 Feb 2022 02:01:54 -0500	[thread overview]
Message-ID: <20220219070155.1924-3-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20220219070155.1924-1-maxim.cournoyer@gmail.com>

* 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 | 55 ++++++++++++++++++++++++++--------------
 2 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d3f9216563..ec1e49630f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -34915,6 +34915,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 179fb12a2b..2f8b114806 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -499,9 +499,9 @@ (define* (boot-system #:key
 KEYMAP-FILE is true), then setting up QEMU guest networking if
 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 parameters 'gnu.load' and 'gnu.repl'.  It also
+supports the kernel command-line options 'gnu.load' and 'gnu.repl'.  It also
 honors a subset of the Linux kernel command-line parameters such as
-'fsck.mode', 'resume', 'root' and 'rootdelay'.
+'fsck.mode', 'resume', 'rootdelay', rootflags and rootfstype.
 
 Mount the root file system, specified by the 'root' command-line argument, if
 any.
@@ -537,13 +537,30 @@ (define (device-string->file-system-device device-string)
              ;; 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 +632,18 @@ (define (repair fs)
 
         (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 the specified non-root file systems.
         (for-each (lambda (fs)
-- 
2.34.0





  parent reply	other threads:[~2022-02-19  7:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 13:53 bug#40998: Guix System's initrd doesn't honor rootflags maxim.cournoyer
2022-02-18 15:33 ` bug#40998: [PATCH 1/3] initrd: Rename the '--root' initrd option to just 'root' Maxim Cournoyer
2022-02-18 15:33   ` bug#40998: [PATCH 2/3] initrd: Honor rootfstype and rootflags command-line parameters Maxim Cournoyer
2022-02-18 15:33   ` bug#40998: [PATCH 3/3] initrd: Print its " Maxim Cournoyer
2022-02-19  7:01 ` bug#40998: [PATCH v2 1/4] system: Add a version field to the <boot-parameters> record Maxim Cournoyer
2022-02-19  7:01   ` bug#40998: [PATCH v2 2/4] initrd: Use non-hyphenated kernel command-line parameter names Maxim Cournoyer
2022-02-27 21:03     ` bug#40998: Guix System's initrd doesn't honor rootflags Ludovic Courtès
2022-02-28 20:31       ` Maxim Cournoyer
2022-02-19  7:01   ` Maxim Cournoyer [this message]
2022-02-27 21:06     ` Ludovic Courtès
2022-02-19  7:01   ` bug#40998: [PATCH v2 4/4] initrd: Print its command-line parameters Maxim Cournoyer
2022-02-27 21:08     ` bug#40998: Guix System's initrd doesn't honor rootflags Ludovic Courtès
2022-02-28 20:36       ` Maxim Cournoyer
2022-02-28  3:45     ` bug#40998: [PATCH v2 4/4] initrd: Print its command-line parameters Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-02-28 15:54       ` Maxim Cournoyer
2022-02-27 20:54   ` bug#40998: Guix System's initrd doesn't honor rootflags Ludovic Courtès
2022-02-28 20:02     ` Maxim Cournoyer
2022-02-28 21:15       ` Ludovic Courtès
2022-02-28 21:45         ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220219070155.1924-3-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=40998@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).