From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:39849) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1ngk-0001RJ-Er for guix-patches@gnu.org; Wed, 12 Feb 2020 03:48:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1ngg-0002Ei-SK for guix-patches@gnu.org; Wed, 12 Feb 2020 03:48:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:51831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j1ngg-0002EH-Ks for guix-patches@gnu.org; Wed, 12 Feb 2020 03:48:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j1ngg-0008K8-IL for guix-patches@gnu.org; Wed, 12 Feb 2020 03:48:02 -0500 Subject: [bug#37305] [PATCH] Allow booting from a Btrfs subvolume. Resent-Message-ID: From: Maxim Cournoyer References: <87sgpby4p9.fsf@gmail.com> <87y2yg3t3s.fsf@gnu.org> Date: Wed, 12 Feb 2020 03:47:40 -0500 In-Reply-To: <87y2yg3t3s.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 22 Sep 2019 23:43:03 +0200") Message-ID: <87k14sfaz7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 37305@debbugs.gnu.org --=-=-= Content-Type: text/plain Hello Ludovic! My much delayed answer to your review are the attached, much improved patches. The new test passes and I'm already using this on one of my system successfully. Thanks for your patience, Maxim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-tests-Reduce-the-time-required-to-run-the-system.patch Content-Transfer-Encoding: quoted-printable >From 3640bea548826e1c1ec9b766da1fdfe4791d7452 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 17 Nov 2019 06:01:00 +0900 Subject: [PATCH 1/8] gnu: tests: Reduce the time required to run the system tests. When setting the GUIX_DEV_HACKS environment variable, the Guix package used inside the instrumented VMs recycles the binaries already found in the Guix checkout of the developer instead of rebuilding Guix from scratch. This brings the time required for this component from 20+ minutes down to 2-3 minutes on an X200 machine. * gnu/packages/package-management.scm (current-guix/pre-built): New procedu= re. * build-aux/run-system-tests.scm (tests-for-channel-instance): Use it, when GUIX_DEV_HACKS is defined. --- build-aux/run-system-tests.scm | 11 ++++- gnu/packages/package-management.scm | 66 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/build-aux/run-system-tests.scm b/build-aux/run-system-tests.scm index b0cb3bd2bf..04b6fa29c3 100644 --- a/build-aux/run-system-tests.scm +++ b/build-aux/run-system-tests.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2016, 2018, 2019 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -58,8 +59,16 @@ instance." ;; of tests to run in the usual way: ;; ;; make check-system TESTS=3Dinstalled-os + + ;; When the GUIX_DEV_HACKS environment variable is defined, override the + ;; package returned by `current-guix' with a flavor that saves recompili= ng + ;; Guix from scratch and reuse the developer's checkout binaries. The + ;; override "builds" about 20 times faster than the regular `current-gui= x' + ;; package, which can help speed iterative development. (parameterize ((current-guix-package - (channel-instance->package instance))) + (if (getenv "GUIX_DEV_HACKS") + (current-guix/pre-built) + (channel-instance->package instance)))) (match (getenv "TESTS") (#f (all-system-tests)) diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-man= agement.scm index 422d4f1959..bd2ed85189 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -468,6 +468,72 @@ out) and returning a package that uses that as its 'so= urce'." #:recursive? #t #:select? (force select?)))))))) =20 +(define-public (current-guix/pre-built) + "Similar to `current-guix', but with a modified build procedure that +reuses the existing byte compiled artifacts to save recompilation time." + + (let* ( ;; The `current-source-directory' macro doesn't work from the RE= PL. + ;; For testing, you can replace it with a static string pointing = to + ;; your Guix checkout directory. + (repository-root (delay (canonicalize-path + (string-append (current-source-directory) + "/../..")))) + (select? (lambda (file stat) + (match (basename file) + ((or ".git" + "configure" "autom4te.cache" + "config.log" "config.status" + "stamp-1" "stamp-2" "stamp-3" "stamp-4" "stamp-= 5" + "stamp-h1" "stamp-vti" + "Makefile" "Makefile.in" ".libs" + ".deps" ".dirstamp" + "test-tmp" + ) #f) + (_ #t))))) + (package + (inherit guix) + (version (string-append (package-version guix) "+")) + (source (local-file (force repository-root) "guix-current" + #:recursive? #t + #:select? select?)) + (arguments + (substitute-keyword-arguments (package-arguments guix) + ((#:phases phases) + `(modify-phases ,phases + ;; XXX: References to tools such as 'mkdir' and 'install' are + ;; captured in Makefile.in when 'autoconf' is run. It'd be n= icer + ;; to find those at configuration time. + (delete 'copy-bootstrap-guile) + (delete 'check) + (delete 'disable-failing-tests) + (delete 'strip) ;can't strip .go files anyway + (replace 'build + (lambda _ + ;; Set the write permission bit on some files that need t= o be + ;; touched. + (chmod "nix" #o777) + (for-each (lambda (f) + (chmod f #o666)) + (cons* "guix-daemon" + (find-files "." ".*\\.(a|o)$"))) + + ;; The following prevent 'make install' from rebuilding t= he + ;; daemon and the documentation. + (invoke "make" "--touch" "info" + ;; TODO: Currently we must rebuild the daemon as = it + ;; was linked against external dependencies that + ;; depend on the provenance of the profile (or + ;; environment) that was used to build it. + + ;; If we could query the provenance of any profil= e, + ;; we could make this package inherit from the gu= ix + ;; inferior that was used to provide such + ;; dependencies. The most reliable way would + ;; probably be to record that provenance at build + ;; time (as a make target). + ;"guix-daemon" + )))))))))) + ;;; ;;; Other tools. --=20 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-gnu-linux-boot-Ensure-volatile-root-is-mounted-read-.patch >From 97d8a635eba34c7cf0708e99bf77ef9bad1344bf Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 11 Feb 2020 12:57:29 -0500 Subject: [PATCH 2/8] gnu: linux-boot: Ensure volatile root is mounted read-only. * gnu/build/linux-boot.scm (mount-root-file-system): Ensure MS_RDONLY is present among the root file system flags when VOLATILE-ROOT? is #t. --- gnu/build/linux-boot.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 3d40a7d05d..4fb711b8f2 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -362,12 +362,12 @@ the last argument of `mknod'." "Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT? is true, mount ROOT read-only and make it an overlay with a writable tmpfs using the kernel built-in overlayfs. FLAGS and OPTIONS indicates the options to use -to mount ROOT." +to mount ROOT, and behave the same as for the `mount' procedure." (if volatile-root? (begin (mkdir-p "/real-root") - (mount root "/real-root" type MS_RDONLY options) + (mount root "/real-root" type (logior MS_RDONLY flags) options) (mkdir-p "/rw-root") (mount "none" "/rw-root" "tmpfs") -- 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-file-systems-Add-a-file-system-device-string-procedu.patch >From 870277ade6c20546566161adbe3e6f4a5c4368a8 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 11 Feb 2020 23:56:45 -0500 Subject: [PATCH 3/8] file-systems: Add a 'file-system-device->string' procedure. * gnu/system/file-systems.scm (file-system-device->string): New procedure. * gnu/system.scm (bootable-kernel-arguments): Use it. * gnu/system/vm.scm (operating-system-uuid): Likewise. * guix/scripts/system.scm (display-system-generation): Likewise. --- gnu/system.scm | 15 +++++---------- gnu/system/file-systems.scm | 13 +++++++++++++ gnu/system/vm.scm | 8 +------- guix/scripts/system.scm | 7 +------ 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 01baa248a2..2e6d03272d 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -142,16 +142,11 @@ (define (bootable-kernel-arguments system root-device) "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE." (list (string-append "--root=" - (cond ((uuid? root-device) - - ;; Note: Always use the DCE format because that's - ;; what (gnu build linux-boot) expects for the - ;; '--root' kernel command-line option. - (uuid->string (uuid-bytevector root-device) - 'dce)) - ((file-system-label? root-device) - (file-system-label->string root-device)) - (else root-device))) + ;; Note: Always use the DCE format because that's what + ;; (gnu build linux-boot) expects for the '--root' + ;; kernel command-line option. + (file-system-device->string root-device + #:uuid-type 'dce)) #~(string-append "--system=" #$system) #~(string-append "--load=" #$system "/boot"))) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index d47a514b66..70a6febe3d 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -30,6 +30,7 @@ #:export (file-system file-system? file-system-device + file-system-device->string file-system-title ;deprecated file-system-mount-point file-system-type @@ -235,6 +236,18 @@ where both FILE1 and FILE2 are absolute file name. For example: (() #f))))))) +(define* (file-system-device->string device #:key (uuid-type 'dce)) + "Return the string representations of the DEVICE field of a +record. When the device is a UUID, its representation is chosen depening on +UUID-TYPE, a symbol such as 'dce or 'iso9660." + (match device + ((? file-system-label?) + (file-system-label->string device)) + ((? uuid?) + (uuid->string device)) + ((? string?) + device))) + (define (file-system-needed-for-boot? fs) "Return true if FS has the 'needed-for-boot?' flag set, or if it holds the store--e.g., if FS is the root file system." diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 81b2e06ba2..03a511cdde 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -609,13 +609,7 @@ TYPE (one of 'iso9660 or 'dce). Return a UUID object." (let ((device (file-system-device fs))) (list (file-system-mount-point fs) (file-system-type fs) - (cond ((file-system-label? device) - (file-system-label->string device)) - ((uuid? device) - (uuid->string device)) - ((string? device) - device) - (else #f)) + (file-system-device->string device) (file-system-options fs)))) (if (eq? type 'iso9660) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index e69a3b6c97..b0386a1392 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -517,12 +517,7 @@ list of services." (cond ((uuid? root-device) 0) ((file-system-label? root-device) 1) (else 2)) - (cond ((uuid? root-device) - (uuid->string root-device)) - ((file-system-label? root-device) - (file-system-label->string root-device)) - (else - root-device))) + (file-system-device->string root-device)) (format #t (G_ " kernel: ~a~%") kernel) -- 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-gnu-linux-boot-Refactor-boot-system.patch >From 347cccca292119104383aa7116b5eb7473d8a51b Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 11 Feb 2020 14:00:06 -0500 Subject: [PATCH 4/8] gnu: linux-boot: Refactor boot-system. The --root option can now be omitted, and inferred from the root file system declaration instead. * gnu/build/linux-boot.scm (boot-system): Remove nested definitions for root-fs-type, root-fs-flags and root-fs-options, and bind those inside the let* instead. Make "--root" take precendence over the device field string representation of the root file system. * doc/guix.texi (Initial RAM Disk): Document that "--root" can be left unspecified. --- doc/guix.texi | 7 ++++--- gnu/build/linux-boot.scm | 42 +++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 42d7cfa2e8..85cfabc2f3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -25917,9 +25917,10 @@ service activation programs and then spawns the GNU@tie{}Shepherd, the initialization system. @item --root=@var{root} -Mount @var{root} as the root file system. @var{root} can be a -device name like @code{/dev/sda1}, a file system label, or a file system -UUID. +Mount @var{root} as the root file system. @var{root} can be a device +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 --system=@var{system} Have @file{/run/booted-system} and @file{/run/current-system} point to diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 4fb711b8f2..28697e7bbf 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -467,26 +467,6 @@ upon error." (define (root-mount-point? fs) (string=? (file-system-mount-point fs) "/")) - (define root-fs-type - (or (any (lambda (fs) - (and (root-mount-point? fs) - (file-system-type fs))) - mounts) - "ext4")) - - (define root-fs-flags - (mount-flags->bit-mask (or (any (lambda (fs) - (and (root-mount-point? fs) - (file-system-flags fs))) - mounts) - '()))) - - (define root-fs-options - (any (lambda (fs) - (and (root-mount-point? fs) - (file-system-options fs))) - mounts)) - (display "Welcome, this is GNU's early boot Guile.\n") (display "Use '--repl' for an initrd REPL.\n\n") @@ -495,7 +475,25 @@ upon error." (mount-essential-file-systems) (let* ((args (linux-command-line)) (to-load (find-long-option "--load" args)) - (root (find-long-option "--root" args))) + (root-fs (find root-mount-point? mounts)) + (root-fs-type (or (and=> root-fs file-system-type) + "ext4")) + (root-device (and=> root-fs file-system-device)) + (root-device-str (and=> root-device file-system-device->string)) + ;; --root takes precedence over the 'device' field of the root + ;; record. + (root (or (find-long-option "--root" args) + root-device-str)) + (root-fs-flags (mount-flags->bit-mask + (or (and=> root-fs file-system-flags) + '()))) + (root-fs-options (if root-fs + (file-system-options root-fs) + '())) + (root-options (if (null? root-fs-options) + #f + (file-system-options->str + root-fs-options)))) (when (member "--repl" args) (start-repl)) @@ -541,7 +539,7 @@ upon error." root-fs-type #:volatile-root? volatile-root? #:flags root-fs-flags - #:options root-fs-options)) + #:options root-options)) (mount "none" "/root" "tmpfs")) ;; Mount the specified file systems. -- 2.25.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0005-file-systems-Represent-the-file-system-options-as-an.patch Content-Transfer-Encoding: quoted-printable >From 38286c910480a7102f9ae52c731eeea363f567f2 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 25 Sep 2019 22:43:41 +0900 Subject: [PATCH 5/8] file-systems: Represent the file system options as an alist. This allows accessing the parameter values easily, without having to parse a string. * gnu/system/file-systems.scm (): Update the default value of = the OPTIONS field, doc. (%file-system-options): Field accessor renamed from `file-system-options'. (file-system-options, file-system-options->string): New procedures. * gnu/build/file-systems.scm (mount-file-system): Adapt. * gnu/services/base.scm (file-system->fstab-entry): Likewise. * tests/file-systems.scm: New tests. * doc/guix.texi (File Systems): Document the modified default value of the 'file-system-options' field. --- doc/guix.texi | 11 ++++++----- gnu/build/file-systems.scm | 15 +++++++++------ gnu/services/base.scm | 35 +++++++++++++++++++---------------- gnu/system/file-systems.scm | 35 +++++++++++++++++++++++++++++++++-- tests/file-systems.scm | 24 ++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 29 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 85cfabc2f3..5d526b1aee 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11405,11 +11405,12 @@ update time on the in-memory version of the file = inode), and @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference Manual}, for more information on these flags. =20 -@item @code{options} (default: @code{#f}) -This is either @code{#f}, or a string denoting mount options passed to the -file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library -Reference Manual}, for details and run @command{man 8 mount} for options f= or -various file systems. +@item @code{options} (default: @code{'()}) +A list of parameters and/or of pairs of parameter name and values, as +strings. Those represent the mount options that are passed to the file +system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library +Reference Manual}, for details and run @command{man 8 mount} for options +for various file systems. =20 @item @code{mount?} (default: @code{#t}) This value indicates whether to automatically mount the file system when diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index ee6375515f..cfa3898f83 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -662,12 +662,15 @@ corresponds to the symbols listed in FLAGS." (if options (string-append "," options) ""))))) - (let ((type (file-system-type fs)) - (options (file-system-options fs)) - (source (canonicalize-device-spec (file-system-device fs))) - (mount-point (string-append root "/" - (file-system-mount-point fs))) - (flags (mount-flags->bit-mask (file-system-flags fs)))) + (let* ((type (file-system-type fs)) + (fs-options (file-system-options fs)) + (options (if (null? fs-options) + #f + (file-system-options->string fs-options))) + (source (canonicalize-device-spec (file-system-device fs))) + (mount-point (string-append root "/" + (file-system-mount-point fs))) + (flags (mount-flags->bit-mask (file-system-flags fs)))) (when (file-system-check? fs) (check-file-system source type)) =20 diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 0c154d1c4e..6104b47870 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -313,22 +313,25 @@ seconds after @code{SIGTERM} has been sent are termin= ated with =20 (define (file-system->fstab-entry file-system) "Return a @file{/etc/fstab} entry for @var{file-system}." - (string-append (match (file-system-device file-system) - ((? file-system-label? label) - (string-append "LABEL=3D" - (file-system-label->string label))) - ((? uuid? uuid) - (string-append "UUID=3D" (uuid->string uuid))) - ((? string? device) - device)) - "\t" - (file-system-mount-point file-system) "\t" - (file-system-type file-system) "\t" - (or (file-system-options file-system) "defaults") "\t" - - ;; XXX: Omit the 'fs_freq' and 'fs_passno' fields because= we - ;; don't have anything sensible to put in there. - )) + (let ((options (file-system-options file-system))) + (string-append (match (file-system-device file-system) + ((? file-system-label? label) + (string-append "LABEL=3D" + (file-system-label->string label))) + ((? uuid? uuid) + (string-append "UUID=3D" (uuid->string uuid))) + ((? string? device) + device)) + "\t" + (file-system-mount-point file-system) "\t" + (file-system-type file-system) "\t" + (if (null? options) + "defaults" + (file-system-options->string options)) "\t" + + ;; XXX: Omit the 'fs_freq' and 'fs_passno' fields becau= se we + ;; don't have anything sensible to put in there. + ))) =20 (define (file-systems->fstab file-systems) "Return a @file{/etc} entry for an @file{fstab} describing diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 70a6febe3d..eff89f146c 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Cour= t=C3=A8s +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ file-system-needed-for-boot? file-system-flags file-system-options + file-system-options->string file-system-mount? file-system-check? file-system-create-mount-point? @@ -97,8 +99,8 @@ (type file-system-type) ; string (flags file-system-flags ; list of symbols (default '())) - (options file-system-options ; string or #f - (default #f)) + (options %file-system-options ; list of strings and/or + (default '())) ; pair of strings (mount? file-system-mount? ; Boolean (default #t)) (needed-for-boot? %file-system-needed-for-boot? ; Boolean @@ -248,6 +250,35 @@ UUID-TYPE, a symbol such as 'dce or 'iso9660." ((? string?) device))) =20 +(define (file-system-options fs) + "Return the options of a record, as a list of options or +option/value pairs." + + ;; Support the deprecated options format (a string). + (define (options-string->options-list str) + (let ((option-list (string-split str #\,))) + (map (lambda (param) + (if (string-contains param "=3D") + (apply cons (string-split param #\=3D)) + param)) + option-list))) + + (let ((fs-options (%file-system-options fs))) + (if (string? fs-options) + (options-string->options-list fs-options) + fs-options))) + +(define (file-system-options->string options) + "Return the string representation of the OPTIONS field of a +record" + (string-join (map (match-lambda + ((key . value) + (string-append key "=3D" value)) + (key + key)) + options) + ",")) + (define (file-system-needed-for-boot? fs) "Return true if FS has the 'needed-for-boot?' flag set, or if it holds t= he store--e.g., if FS is the root file system." diff --git a/tests/file-systems.scm b/tests/file-systems.scm index 4c28d0ebc5..b9f4f50aad 100644 --- a/tests/file-systems.scm +++ b/tests/file-systems.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015, 2017 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,4 +65,27 @@ (_ #f)) (source-module-closure '((gnu system file-systems))))) =20 +(define %fs-with-deprecated-options-string + (file-system + (device (file-system-label "btrfs-pool")) + (mount-point "/home") + (type "btrfs") + (options "autodefrag,subvol=3Dhome,compress=3Dlzo"))) + +(define %fs + (file-system + (device (file-system-label "btrfs-pool")) + (mount-point "/root") + (type "btrfs") + (options '("autodefrag" ("subvol" . "root") ("compress" . "lzo"))))) + +(test-equal " options given as a string (deprecated)" + '("autodefrag" ("subvol" . "home") ("compress" . "lzo")) + (file-system-options %fs-with-deprecated-options-string)) + +(test-equal " options conversion to string" + "autodefrag,subvol=3Droot,compress=3Dlzo" + (file-system-options->string + (file-system-options %fs))) + (test-end) --=20 2.25.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0006-gnu-linux-boot-Honor-the-root-options-kernel-argumen.patch Content-Transfer-Encoding: quoted-printable >From de7043998f2a2877f47e7952a435b711a0cbe9b5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 11 Feb 2020 14:14:36 -0500 Subject: [PATCH 6/8] gnu: linux-boot: Honor the "--root-options" kernel argument. * gnu/build/linux-boot.scm (boot-system): Parse the "--root-options" kernel argument, and use it when calling `mount-root-file-system'. Update doc. * doc/guix.texi (Initial RAM Disk): Document the use of the "--root-options" argument. --- doc/guix.texi | 10 ++++++++++ gnu/build/linux-boot.scm | 15 ++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5d526b1aee..d6bfbd7b55 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -25935,6 +25935,16 @@ Instruct the initial RAM disk as well as the @comm= and{modprobe} command must be a comma-separated list of module names---e.g., @code{usbkbd,9pnet}. =20 +@item --root-options=3D@var{options}@dots{} +@cindex mount options for the root file system, passed to initrd +@cindex rootflags, initrd +@cindex root-options, initrd +This argument allows passing one or multiple file system specific mount +options used by the initrd to mount the root file system. @var{options} +must be a comma-separated list of option names or option-value pairs. +When unspecified, the value of the options field of the root file system +of the operating system declaration is used. + @item --repl Start a read-eval-print loop (REPL) from the initial RAM disk before it tries to load kernel modules and to mount the root file system. Our diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 28697e7bbf..f65e942ebc 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Cour= t=C3=A8s ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2019 Guillaume Le Vaillant +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -452,7 +453,8 @@ LINUX-MODULE-DIRECTORY, then installing KEYMAP-FILE wit= h 'loadkeys' (if KEYMAP-FILE is true), then setting up QEMU guest networking if QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file syste= ms specified in MOUNTS, and finally booting into the new root if any. The in= itrd -supports kernel command-line options '--load', '--root', and '--repl'. +supports kernel command-line options '--load', '--root', '--root-options' = and +'--repl'. =20 Mount the root file system, specified by the '--root' command-line argumen= t, if any. @@ -490,10 +492,13 @@ upon error." (root-fs-options (if root-fs (file-system-options root-fs) '())) - (root-options (if (null? root-fs-options) - #f - (file-system-options->str - root-fs-options)))) + ;; --root-options takes precedence over the 'options' field o= f the + ;; root record. + (root-options (or (find-long-option "--root-options" args) + (if (null? root-fs-options) + #f + (file-system-options->string + root-fs-options))))) =20 (when (member "--repl" args) (start-repl)) --=20 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0007-gnu-linux-boot-Filter-out-file-system-independent-op.patch >From 549d585266e32cf413ae0511edd315f615f0c3a9 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 11 Feb 2020 14:27:19 -0500 Subject: [PATCH 7/8] gnu: linux-boot: Filter out file system independent options. This fixes an issue where options such as "defaults", which are understood by the command line program "mount", are not understood by the system call of the same name, which is used in the initial RAM disk. * gnu/system/file-systems.scm (%file-system-independent-mount-options): New variable. (file-system-independent-mount-option?): New predicate. * gnu/build/linux-boot.scm (boot-system): Use the above predicate to filter out system independent mount options. --- gnu/build/linux-boot.scm | 3 ++- gnu/system/file-systems.scm | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index f65e942ebc..8e55797549 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -490,7 +490,8 @@ upon error." (or (and=> root-fs file-system-flags) '()))) (root-fs-options (if root-fs - (file-system-options root-fs) + (remove file-system-independent-mount-option? + (file-system-options root-fs)) '())) ;; --root-options takes precedence over the 'options' field of the ;; root record. diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index eff89f146c..2dcf41ba57 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -46,6 +46,7 @@ file-system-location file-system-type-predicate + file-system-independent-mount-option? file-system-label file-system-label? @@ -563,4 +564,20 @@ system has the given TYPE." (lambda (fs) (string=? (file-system-type fs) type))) +(define %file-system-independent-mount-options + ;; Taken from 'man 8 mount'. + '("async" "atime" "auto" "noatime" "noauto" "context" "defaults" "dev" "nodev" + "diratime" "nodiratime" "dirsync" "exec" "noexec" "group" "iversion" + "noiversion" "mand" "nomand" "_netdev" "nofail" "relatime" "norelatime" + "strictatime" "nostrictatime" "lazytime" "nolazytime" "suid" "nosuid" + "silent" "loud" "owner" "remount" "ro" "rw" "sync" "user" "nouser" "users")) + +(define (file-system-independent-mount-option? option) + "Predicate to check if a option is file system independent." + (let ((option-name (if (pair? option) + (car option) + option))) + (or (string-prefix-ci? "x-" option-name) + (member option-name %file-system-independent-mount-options)))) + ;;; file-systems.scm ends here -- 2.25.0 --=-=-=--