From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 28 17:52:17 2022 Received: (at 40998) by debbugs.gnu.org; 28 Feb 2022 22:52:17 +0000 Received: from localhost ([127.0.0.1]:34952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOosL-0008Dj-2t for submit@debbugs.gnu.org; Mon, 28 Feb 2022 17:52:17 -0500 Received: from mail-qv1-f43.google.com ([209.85.219.43]:43645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOosJ-0008DX-7Y for 40998@debbugs.gnu.org; Mon, 28 Feb 2022 17:52:15 -0500 Received: by mail-qv1-f43.google.com with SMTP id c14so10360211qvk.10 for <40998@debbugs.gnu.org>; Mon, 28 Feb 2022 14:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oGwEV7PuA3bNVUKM6x8VA5DOL7o1D+uFX1eqitS6RjE=; b=iSG86jJ4cI+6S8ZP//30VfF6T8xpxqCvwRg2G8ZL/6v7ZD9qSwViBEXV4aJ5EngJia eJGc6gSo9c71EvsVVIcd6wEnJ/1UVAGMBxTrbyeSZpyWoWjo7aRjCNS5XFHfh66iCcbV /sM7cY2lNA0lERF+asIneyvsf4SN6hFgeSfLwrO1Z13HIEOtXGqDIIMUz93cSOu10VK9 Us7rpJSUX2zjw1J+IaUQn7bsxGaz0gTEIa5vxcGaaYcurkkCgGLLurxgG6MUqMq6IbQX Y6A/JbQ7QtPrXqT0dyoWa30tGzMUpSQMNFmItAQo8ZS+jwEUBec9oTXV8xnmto24jT7+ BIVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oGwEV7PuA3bNVUKM6x8VA5DOL7o1D+uFX1eqitS6RjE=; b=UzK10BLiN/fuv7YXy0d05Zn77tIIyB1LoqcIt6tPHwVtYmgh87zswitSjDu8u4LfzJ SyUeyjvNIBs6VFbgEphAR7wnQusgImLhSqt9x9waifYEDtWjNplEl3QkC3zPT+Ni303T I3RPjRA0WyKuHFhwLjDRuRxHcdRcdkMTHzYTHfpRK63xgXVmzWpUodmT8a0zmkuAyxpZ weAXfk67NDXHivF/y7Xd00Jol0B7RDZoDNLn3KqOxmiaLSlzm2fWRm+pG0xAG72nVm+f UKKFDAf7oB74yweW35ncL0lhs3/KRd93Cz+yb+xhm0yP9O+z2KflBpmEVBzv70pY069s aILg== X-Gm-Message-State: AOAM5323rLwB+AFkZweqrCl9zvEkuHGaNWW5D/ZdxUykUDrAZTnBSBvD Tgq8c2AUVUd/oYJTL8eWwuJI21CHlne83A== X-Google-Smtp-Source: ABdhPJxiN/HnJQkGC7+cLFR7d9p4mKOqWY2jYPfS2kPs1KQ3V/YlDCRLDpBFF8pXLQ0PP5rFsJIJ5w== X-Received: by 2002:ac8:4e09:0:b0:2ca:c94b:2c37 with SMTP id c9-20020ac84e09000000b002cac94b2c37mr17667534qtw.338.1646088729556; Mon, 28 Feb 2022 14:52:09 -0800 (PST) Received: from localhost.localdomain (dsl-141-227.b2b2c.ca. [66.158.141.227]) by smtp.gmail.com with ESMTPSA id b17-20020ae9eb11000000b0064917bda713sm5562714qkg.85.2022.02.28.14.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 14:52:09 -0800 (PST) From: Maxim Cournoyer To: 40998@debbugs.gnu.org Subject: [PATCH 4/4] initrd: Honor rootfstype and rootflags command-line parameters. Date: Mon, 28 Feb 2022 17:50:46 -0500 Message-Id: <20220228225047.11105-4-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220228225047.11105-1-maxim.cournoyer@gmail.com> References: <20220228225047.11105-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 40998 Cc: ludo@gnu.org, me@tobias.gr, Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * 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 ce44eb3b47..dc6cb9842e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -34973,6 +34973,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 cfa1ab2fcb..7d41537652 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -500,9 +500,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. @@ -538,13 +538,30 @@ (define (device-string->file-system-device device-string) ;; over the ‘device’ field of the root 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 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) @@ -616,18 +633,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