initrd: Use non-hyphenated kernel command-line parameter names.

This is to make it less surprising, given the common convention sets forth by
the kernel Linux command-line parameters.

* gnu/build/linux-boot.scm (boot-system): Rename '--load', '--repl', '--root'
and '--system' to 'gnu.load', 'gnu.repl', 'root' and 'gnu.system',
respectively.  Adjust doc.
(find-long-option): Adjust doc.
* gnu/installer/parted.scm (installer-root-partition-path): Adjust accordingly.
* gnu/system.scm (bootable-kernel-arguments): Add a VERSION argument and
update doc.  Use VERSION to conditionally return old style vs new style initrd
arguments.
(%boot-parameters-version): Increment to 1.
(operating-system-boot-parameters): Adjust doc.
(operating-system-boot-parameters-file): Likewise.
* gnu/system/linux-initrd.scm (raw-initrd, base-initrd): Likewise.
* doc/guix.texi: Adjust doc.
* gnu/build/activation.scm (boot-time-system): Adjust accordingly.
* gnu/build/hurd-boot.scm (boot-hurd-system): Likewise.
* gnu/packages/commencement.scm (%final-inputs-riscv64): Adjust comment.
This commit is contained in:
Maxim Cournoyer 2022-02-17 23:28:07 -05:00
parent 91755fe6b2
commit 0dc019e19a
No known key found for this signature in database
GPG key ID: 1260E46482E63562
9 changed files with 69 additions and 53 deletions

View file

@ -34959,7 +34959,7 @@ honors several options passed on the Linux kernel command line
@code{-append} option of QEMU), notably: @code{-append} option of QEMU), notably:
@table @code @table @code
@item --load=@var{boot} @item gnu.load=@var{boot}
Tell the initial RAM disk to load @var{boot}, a file containing a Scheme Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
program, once it has mounted the root file system. program, once it has mounted the root file system.
@ -34967,7 +34967,7 @@ Guix uses this option to yield control to a boot program that runs the
service activation programs and then spawns the GNU@tie{}Shepherd, the service activation programs and then spawns the GNU@tie{}Shepherd, the
initialization system. initialization system.
@item --root=@var{root} @item root=@var{root}
Mount @var{root} as the root file system. @var{root} can be a device 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. 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 When unspecified, the device name from the root file system of the
@ -34992,7 +34992,7 @@ or @code{preen} to repair problems considered safe to repair automatically.
@code{preen} is the default if this option is not present or if @var{level} @code{preen} is the default if this option is not present or if @var{level}
is not one of the above. is not one of the above.
@item --system=@var{system} @item gnu.system=@var{system}
Have @file{/run/booted-system} and @file{/run/current-system} point to Have @file{/run/booted-system} and @file{/run/current-system} point to
@var{system}. @var{system}.
@ -35004,7 +35004,7 @@ Instruct the initial RAM disk as well as the @command{modprobe} command
must be a comma-separated list of module names---e.g., must be a comma-separated list of module names---e.g.,
@code{usbkbd,9pnet}. @code{usbkbd,9pnet}.
@item --repl @item gnu.repl
Start a read-eval-print loop (REPL) from the initial RAM disk before it 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 tries to load kernel modules and to mount the root file system. Our
marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
@ -35025,7 +35025,7 @@ here is how to use it and customize it further.
[#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f] [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
Return a derivation that builds a raw initrd. @var{file-systems} is Return a derivation that builds a raw initrd. @var{file-systems} is
a list of file systems to be mounted by the initrd, possibly in addition to a list of file systems to be mounted by the initrd, possibly in addition to
the root file system specified on the kernel command line via @option{--root}. the root file system specified on the kernel command line via @option{root}.
@var{linux-modules} is a list of kernel modules to be loaded at boot time. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
@var{mapped-devices} is a list of device mappings to realize before @var{mapped-devices} is a list of device mappings to realize before
@var{file-systems} are mounted (@pxref{Mapped Devices}). @var{file-systems} are mounted (@pxref{Mapped Devices}).
@ -35055,7 +35055,7 @@ to it are lost.
Return as a file-like object a generic initrd, with kernel Return as a file-like object a generic initrd, with kernel
modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
mounted by the initrd, possibly in addition to the root file system specified mounted by the initrd, possibly in addition to the root file system specified
on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device on the kernel command line via @option{root}. @var{mapped-devices} is a list of device
mappings to realize before @var{file-systems} are mounted. mappings to realize before @var{file-systems} are mounted.
When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting

View file

@ -389,8 +389,8 @@ (define %current-system
"/run/current-system") "/run/current-system")
(define (boot-time-system) (define (boot-time-system)
"Return the '--system' argument passed on the kernel command line." "Return the 'gnu.system' argument passed on the kernel command line."
(find-long-option "--system" (if (string-contains %host-type "linux-gnu") (find-long-option "gnu.system" (if (string-contains %host-type "linux-gnu")
(linux-command-line) (linux-command-line)
(command-line)))) (command-line))))

View file

@ -254,7 +254,7 @@ (define* (boot-hurd-system #:key (on-error 'debug))
"This procedure is meant to be called from an early RC script. "This procedure is meant to be called from an early RC script.
Install the relevant passive translators on the first boot. Then, run system Install the relevant passive translators on the first boot. Then, run system
activation by using the kernel command-line options '--system' and '--load'; activation by using the kernel command-line options 'gnu.system' and 'gnu.load';
starting the Shepherd. starting the Shepherd.
XXX TODO: see linux-boot.scm:boot-system. XXX TODO: see linux-boot.scm:boot-system.
@ -265,14 +265,14 @@ (define* (boot-hurd-system #:key (on-error 'debug))
" "
(display "Welcome, this is GNU's early boot Guile.\n") (display "Welcome, this is GNU's early boot Guile.\n")
(display "Use '--repl' for an initrd REPL.\n\n") (display "Use 'gnu.repl' for an initrd REPL.\n\n")
(call-with-error-handling (call-with-error-handling
(lambda () (lambda ()
(let* ((args (command-line)) (let* ((args (command-line))
(system (find-long-option "--system" args)) (system (find-long-option "gnu.system" args))
(to-load (find-long-option "--load" args))) (to-load (find-long-option "gnu.load" args)))
(format #t "Setting-up essential translators...\n") (format #t "Setting-up essential translators...\n")
(setenv "PATH" (string-append system "/profile/bin")) (setenv "PATH" (string-append system "/profile/bin"))
@ -286,7 +286,7 @@ (define* (boot-hurd-system #:key (on-error 'debug))
(unless (zero? (system* "/hurd/mach-defpager")) (unless (zero? (system* "/hurd/mach-defpager"))
(format #t "FAILED...Good luck!\n")) (format #t "FAILED...Good luck!\n"))
(cond ((member "--repl" args) (cond ((member "gnu.repl" args)
(format #t "Starting repl...\n") (format #t "Starting repl...\n")
(start-repl)) (start-repl))
(to-load (to-load
@ -298,7 +298,7 @@ (define* (boot-hurd-system #:key (on-error 'debug))
(sleep 2) (sleep 2)
(reboot)) (reboot))
(else (else
(display "no boot file passed via '--load'\n") (display "no boot file passed via 'gnu.load'\n")
(display "entering a warm and cozy REPL\n") (display "entering a warm and cozy REPL\n")
(start-repl))))) (start-repl)))))
#:on-error on-error)) #:on-error on-error))

View file

@ -3,6 +3,7 @@
;;; Copyright © 2016, 2017, 20192021 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2016, 2017, 20192021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net> ;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2020, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -93,7 +94,7 @@ (define (linux-command-line)
get-string-all))) get-string-all)))
(define (find-long-option option arguments) (define (find-long-option option arguments)
"Find OPTION among ARGUMENTS, where OPTION is something like \"--load\". "Find OPTION among ARGUMENTS, where OPTION is something like \"gnu.load\".
Return the value associated with OPTION, or #f on failure." Return the value associated with OPTION, or #f on failure."
(let ((opt (string-append option "="))) (let ((opt (string-append option "=")))
(and=> (find (cut string-prefix? opt <>) (and=> (find (cut string-prefix? opt <>)
@ -499,12 +500,12 @@ (define* (boot-system #:key
KEYMAP-FILE is true), then setting up QEMU guest networking if KEYMAP-FILE is true), then setting up QEMU guest networking if
QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems 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 specified in MOUNTS, and finally booting into the new root if any. The initrd
supports kernel command-line options '--load', '--root', and '--repl'. It supports kernel command-line parameters 'gnu.load' and 'gnu.repl'. It also
also honors a subset of the documented Linux kernel command-line parameters honors a subset of the Linux kernel command-line parameters such as
such as 'fsck.mode', 'resume' and 'rootdelay'. 'fsck.mode', 'resume', 'root' and 'rootdelay'.
Mount the root file system, specified by the '--root' command-line argument, Mount the root file system, specified by the 'root' command-line argument, if
if any. any.
MOUNTS must be a list of <file-system> objects. MOUNTS must be a list of <file-system> objects.
@ -517,25 +518,25 @@ (define (root-mount-point? fs)
(string=? (file-system-mount-point fs) "/")) (string=? (file-system-mount-point fs) "/"))
(define (device-string->file-system-device device-string) (define (device-string->file-system-device device-string)
;; The "--root=SPEC" kernel command-line option always provides a ;; The "root=SPEC" kernel command-line option always provides a string,
;; string, but the string can represent a device, an nfs-root, a UUID, or a ;; but the string can represent a device, an nfs-root, a UUID, or a label.
;; label. So check for all four. ;; So check for all four.
(cond ((string-prefix? "/" device-string) device-string) (cond ((string-prefix? "/" device-string) device-string)
((string-contains device-string ":/") device-string) ; nfs-root ((string-contains device-string ":/") device-string) ; nfs-root
((uuid device-string) => identity) ((uuid device-string) => identity)
(else (file-system-label device-string)))) (else (file-system-label device-string))))
(display "Welcome, this is GNU's early boot Guile.\n") (display "Welcome, this is GNU's early boot Guile.\n")
(display "Use '--repl' for an initrd REPL.\n\n") (display "Use 'gnu.repl' for an initrd REPL.\n\n")
(call-with-error-handling (call-with-error-handling
(lambda () (lambda ()
(mount-essential-file-systems) (mount-essential-file-systems)
(let* ((args (linux-command-line)) (let* ((args (linux-command-line))
(to-load (find-long-option "--load" args)) (to-load (find-long-option "gnu.load" args))
;; If present, --root on the kernel command line takes precedence ;; If present, root on the kernel command line takes precedence
;; over the device field of the root <file-system> record. ;; over the device field of the root <file-system> record.
(root-device (and=> (find-long-option "--root" args) (root-device (and=> (find-long-option "root" args)
device-string->file-system-device)) device-string->file-system-device))
(root-fs (or (find root-mount-point? mounts) (root-fs (or (find root-mount-point? mounts)
;; Fall back to fictitious defaults. ;; Fall back to fictitious defaults.
@ -564,7 +565,7 @@ (define (repair fs)
(_ 'preen)) (_ 'preen))
(file-system-repair fs)))) (file-system-repair fs))))
(when (member "--repl" args) (when (member "gnu.repl" args)
(start-repl)) (start-repl))
(display "loading kernel modules...\n") (display "loading kernel modules...\n")
@ -652,7 +653,7 @@ (define (repair fs)
(sleep 2) (sleep 2)
(reboot)) (reboot))
(begin (begin
(display "no boot file passed via '--load'\n") (display "no boot file passed via 'gnu.load'\n")
(display "entering a warm and cozy REPL\n") (display "entering a warm and cozy REPL\n")
(start-repl))))) (start-repl)))))
#:on-error on-error)) #:on-error on-error))

View file

@ -348,7 +348,7 @@ (define (remove-logical-devices)
(define (installer-root-partition-path) (define (installer-root-partition-path)
"Return the root partition path, or #f if it could not be detected." "Return the root partition path, or #f if it could not be detected."
(let* ((cmdline (linux-command-line)) (let* ((cmdline (linux-command-line))
(root (find-long-option "--root" cmdline))) (root (find-long-option "root" cmdline)))
(and root (and root
(or (and (access? root F_OK) root) (or (and (access? root F_OK) root)
(find-partition-by-label root) (find-partition-by-label root)

View file

@ -422,7 +422,8 @@ (define (read-file path)
(let* ((params (call-with-input-string serialized-params (let* ((params (call-with-input-string serialized-params
read-boot-parameters)) read-boot-parameters))
(root (boot-parameters-root-device params)) (root (boot-parameters-root-device params))
(label (boot-parameters-label params))) (label (boot-parameters-label params))
(version (boot-parameters-version params)))
(boot-parameters (boot-parameters
(inherit params) (inherit params)
(label (label
@ -433,7 +434,7 @@ (define (read-file path)
"~Y-~m-~d ~H:~M")) "~Y-~m-~d ~H:~M"))
")")) ")"))
(kernel-arguments (kernel-arguments
(append (bootable-kernel-arguments system-path root) (append (bootable-kernel-arguments system-path root version)
(boot-parameters-kernel-arguments params)))))))) (boot-parameters-kernel-arguments params))))))))
generations)))) generations))))

View file

@ -3740,10 +3740,10 @@ (define-public %final-inputs
(define-public %final-inputs-riscv64 (define-public %final-inputs-riscv64
;; This is similar to the added (list gcc "lib") elsewhere in this file, but ;; This is similar to the added (list gcc "lib") elsewhere in this file, but
;; due to how (%current-system) is re-defined when performing builds with the ;; due to how (%current-system) is re-defined when performing builds with the
;; '--system' flag, %final-inputs is too early in the evaulation pipeline to ;; 'gnu.system' flag, %final-inputs is too early in the evaulation pipeline to
;; correctly identify the system for which a derivation will be built. Thus, ;; correctly identify the system for which a derivation will be built. Thus,
;; since (%current-system) is re-determined by (guix build-system gnu) after ;; since (%current-system) is re-determined by (guix build-system gnu) after
;; loading %final-inputs but before taking into account the '--system' flag, ;; loading %final-inputs but before taking into account the 'gnu.system' flag,
;; the test for (target-riscv64?) needs to be in (guix build-system gnu), ;; the test for (target-riscv64?) needs to be in (guix build-system gnu),
;; with %final-inputs-riscv64 already available at the same time that ;; with %final-inputs-riscv64 already available at the same time that
;; %final-inputs is available. ;; %final-inputs is available.

View file

@ -187,16 +187,23 @@ (define-module (gnu system)
;;; ;;;
;;; Code: ;;; Code:
(define (bootable-kernel-arguments system root-device) (define* (bootable-kernel-arguments system root-device version)
"Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE." "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE.
(list (string-append "--root=" VERSION is the target version of the boot-parameters record."
;; If the version is newer than 0, we use the new style initrd parameter
;; names, otherwise we use the legacy ones. This is to maintain backward
;; compatibility when producing bootloader configurations for older
;; generations.
(define version>0? (> version 0))
(list (string-append (if version>0? "root=" "--root=")
;; Note: Always use the DCE format because that's what ;; Note: Always use the DCE format because that's what
;; (gnu build linux-boot) expects for the '--root' ;; (gnu build linux-boot) expects for the 'root'
;; kernel command-line option. ;; kernel command-line option.
(file-system-device->string root-device (file-system-device->string root-device
#:uuid-type 'dce)) #:uuid-type 'dce))
#~(string-append "--system=" #$system) #~(string-append (if #$version>0? "gnu.system=" "--system=") #$system)
#~(string-append "--load=" #$system "/boot"))) #~(string-append (if #$version>0? "gnu.load=" "--load=")
#$system "/boot")))
;; System-wide configuration. ;; System-wide configuration.
;; TODO: Add per-field docstrings/stexi. ;; TODO: Add per-field docstrings/stexi.
@ -286,10 +293,12 @@ (define-record-type* <operating-system> operating-system
source-properties->location)) source-properties->location))
(innate))) (innate)))
(define (operating-system-kernel-arguments os root-device) (define* (operating-system-kernel-arguments
"Return all the kernel arguments, including the ones not specified os root-device #:key (version %boot-parameters-version))
directly by the user." "Return all the kernel arguments, including the ones not specified directly
(append (bootable-kernel-arguments os root-device) by the user. VERSION should match that of the target <boot-parameter> record
object that will contain the kernel parameters."
(append (bootable-kernel-arguments os root-device version)
(operating-system-user-kernel-arguments os))) (operating-system-user-kernel-arguments os)))
@ -297,8 +306,12 @@ (define (operating-system-kernel-arguments os root-device)
;;; Boot parameters ;;; Boot parameters
;;; ;;;
;;; Version 1 was introduced early 2022 to mark the departure from long option
;;; names such as '--load' to the more conventional initrd option names like
;;; 'gnu.load'.
;;;
;;; When bumping the boot-parameters version, increment it by one (1). ;;; When bumping the boot-parameters version, increment it by one (1).
(define %boot-parameters-version 0) (define %boot-parameters-version 1)
(define-record-type* <boot-parameters> (define-record-type* <boot-parameters>
boot-parameters make-boot-parameters boot-parameters? boot-parameters make-boot-parameters boot-parameters?
@ -479,10 +492,11 @@ (define (read-boot-parameters-file system)
The object has its kernel-arguments extended in order to make it bootable." The object has its kernel-arguments extended in order to make it bootable."
(let* ((file (string-append system "/parameters")) (let* ((file (string-append system "/parameters"))
(params (call-with-input-file file read-boot-parameters)) (params (call-with-input-file file read-boot-parameters))
(root (boot-parameters-root-device params))) (root (boot-parameters-root-device params))
(version (boot-parameters-version params)))
(boot-parameters (boot-parameters
(inherit params) (inherit params)
(kernel-arguments (append (bootable-kernel-arguments system root) (kernel-arguments (append (bootable-kernel-arguments system root version)
(boot-parameters-kernel-arguments params)))))) (boot-parameters-kernel-arguments params))))))
(define (boot-parameters->menu-entry conf) (define (boot-parameters->menu-entry conf)
@ -1453,10 +1467,10 @@ (define (hurd-multiboot-modules os)
(define* (operating-system-boot-parameters os root-device (define* (operating-system-boot-parameters os root-device
#:key system-kernel-arguments?) #:key system-kernel-arguments?)
"Return a monadic <boot-parameters> record that describes the boot "Return a monadic <boot-parameters> record that describes the boot
parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add the kernel
such as '--root' and '--load' to <boot-parameters>. The arguments 'root', 'gnu.load' and 'gnu.system' to <boot-parameters>. The
SYSTEM-KERNEL-ARGUMENTS? should only be used in necessity, as the '--load' and SYSTEM-KERNEL-ARGUMENTS? should only be used in necessity, as the 'gnu.load'
'--system' values are self-referential (they refer to the system), thus and 'gnu.system' values are self-referential (they refer to the system), thus
susceptible to introduce a cyclic dependency." susceptible to introduce a cyclic dependency."
(let* ((initrd (and (not (operating-system-hurd os)) (let* ((initrd (and (not (operating-system-hurd os))
(operating-system-initrd-file os))) (operating-system-initrd-file os)))

View file

@ -181,7 +181,7 @@ (define* (raw-initrd file-systems
"Return as a file-like object a raw initrd, with kernel "Return as a file-like object a raw initrd, with kernel
modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be
mounted by the initrd, possibly in addition to the root file system specified mounted by the initrd, possibly in addition to the root file system specified
on the kernel command line via '--root'. LINUX-MODULES is a list of kernel on the kernel command line via 'root'. LINUX-MODULES is a list of kernel
modules to be loaded at boot time. MAPPED-DEVICES is a list of device modules to be loaded at boot time. MAPPED-DEVICES is a list of device
mappings to realize before FILE-SYSTEMS are mounted. mappings to realize before FILE-SYSTEMS are mounted.
HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include
@ -375,7 +375,7 @@ (define* (base-initrd file-systems
"Return as a file-like object a generic initrd, with kernel "Return as a file-like object a generic initrd, with kernel
modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be
mounted by the initrd, possibly in addition to the root file system specified mounted by the initrd, possibly in addition to the root file system specified
on the kernel command line via '--root'. MAPPED-DEVICES is a list of device on the kernel command line via 'root'. MAPPED-DEVICES is a list of device
mappings to realize before FILE-SYSTEMS are mounted. mappings to realize before FILE-SYSTEMS are mounted.
When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired When true, KEYBOARD-LAYOUT is a <keyboard-layout> record denoting the desired