unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 30629@debbugs.gnu.org
Subject: [bug#30629] [PATCH 4/5] system: Add 'initrd-modules' field.
Date: Tue, 27 Feb 2018 15:22:44 +0100	[thread overview]
Message-ID: <20180227142245.12674-5-ludo@gnu.org> (raw)
In-Reply-To: <20180227142245.12674-1-ludo@gnu.org>

* gnu/system.scm (<operating-system>)[initrd-modules]: New field.
(operating-system-initrd-file): Pass #:linux-modules to 'make-initrd'.
* gnu/system/linux-initrd.scm (default-initrd-modules): New procedure.
(%base-initrd-modules): New macro.
(base-initrd): Add #:linux-modules and honor it.
* gnu/system/install.scm (embedded-installation-os): Use
'initrd-modules' instead of 'initrd'.
* gnu/tests/install.scm (%raid-root-os): Likewise.
* doc/guix.texi (operating-system Reference): Add 'initrd-modules'.
(Initial RAM Disk): Document it.  Adjust example to not use
 #:extra-modules.
---
 doc/guix.texi               | 42 +++++++++++++++++++++++++++++++++---------
 gnu/system.scm              |  8 ++++++++
 gnu/system/install.scm      |  7 ++-----
 gnu/system/linux-initrd.scm | 34 ++++++++++++++++++++++------------
 gnu/tests/install.scm       | 11 +++++------
 5 files changed, 70 insertions(+), 32 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f9d7e13e2..74f2fee3d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8845,11 +8845,16 @@ the command-line of the kernel---e.g., @code{("console=ttyS0")}.
 @item @code{bootloader}
 The system bootloader configuration object.  @xref{Bootloader Configuration}.
 
+@item @code{initrd-modules} (default: @code{%base-initrd-modules})
+@cindex initrd
+@cindex initial RAM disk
+The list of Linux kernel modules that need to be available in the
+initial RAM disk.  @xref{Initial RAM Disk}.
+
 @item @code{initrd} (default: @code{base-initrd})
-@cindex initrd
-@cindex initial RAM disk
-A two-argument monadic procedure that returns an initial RAM disk for
-the Linux kernel.  @xref{Initial RAM Disk}.
+A monadic procedure that returns an initial RAM disk for the Linux
+kernel.  This field is provided to support low-level customization and
+should rarely be needed for casual use.  @xref{Initial RAM Disk}.
 
 @item @code{firmware} (default: @var{%base-firmware})
 @cindex firmware
@@ -18849,7 +18854,27 @@ root file system as well as an initialization script.  The latter is
 responsible for mounting the real root file system, and for loading any
 kernel modules that may be needed to achieve that.
 
-The @code{initrd} field of an @code{operating-system} declaration allows
+The @code{initrd-modules} field of an @code{operating-system}
+declaration allows you to specify Linux-libre kernel modules that must
+be available in the initrd.  In particular, this is where you would list
+modules needed to actually drive the hard disk where your root partition
+is---although the default value of @code{initrd-modules} should cover
+most use cases.  For example, assuming you need the @code{megaraid_sas}
+module in addition to the default modules to be able to access your root
+file system, you would write:
+
+@example
+(operating-system
+  ;; @dots{}
+  (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
+@end example
+
+@defvr {Scheme Variable} %base-initrd-modules
+This is the list of kernel modules included in the initrd by default.
+@end defvr
+
+Furthermore, if you need lower-level customization, the @code{initrd}
+field of an @code{operating-system} declaration allows
 you to specify which initrd you would like to use.  The @code{(gnu
 system linux-initrd)} module provides three ways to build an initrd: the
 high-level @code{base-initrd} procedure and the low-level
@@ -18862,11 +18887,10 @@ system declaration like this:
 
 @example
 (initrd (lambda (file-systems . rest)
-          ;; Create a standard initrd that has modules "foo.ko"
-          ;; and "bar.ko", as well as their dependencies, in
-          ;; addition to the modules available by default.
+          ;; Create a standard initrd but set up networking
+          ;; with the parameters QEMU expects by default.
           (apply base-initrd file-systems
-                 #:extra-modules '("foo" "bar")
+                 #:qemu-networking? #t
                  rest)))
 @end example
 
diff --git a/gnu/system.scm b/gnu/system.scm
index 71beee825..4a77877fa 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -74,6 +74,7 @@
             operating-system-kernel
             operating-system-kernel-file
             operating-system-kernel-arguments
+            operating-system-initrd-modules
             operating-system-initrd
             operating-system-users
             operating-system-groups
@@ -152,8 +153,13 @@ booted from ROOT-DEVICE"
                     (default '()))                ; list of gexps/strings
   (bootloader operating-system-bootloader)        ; <bootloader-configuration>
 
+
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
+  (initrd-modules operating-system-initrd-modules ; list of strings
+                  (thunked)                       ; it's system-dependent
+                  (default %base-initrd-modules))
+
   (firmware operating-system-firmware             ; list of packages
             (default %base-firmware))
 
@@ -846,6 +852,8 @@ hardware-related operations as necessary when booting a Linux container."
 
   (mlet %store-monad ((initrd (make-initrd boot-file-systems
                                            #:linux (operating-system-kernel os)
+                                           #:linux-modules
+                                           (operating-system-initrd-modules os)
                                            #:mapped-devices mapped-devices)))
     (return (file-append initrd "/initrd"))))
 
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index b61660b4b..37c591ec3 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
@@ -396,10 +396,7 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
     (kernel-arguments
      (cons (string-append "console=" tty)
            (operating-system-user-kernel-arguments installation-os)))
-    (initrd (lambda (fs . rest)
-              (apply base-initrd fs
-                     #:extra-modules extra-modules
-                     rest)))))
+    (initrd-modules (append extra-modules %base-initrd-modules))))
 
 (define beaglebone-black-installation-os
   (embedded-installation-os u-boot-beaglebone-black-bootloader
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 830445ac8..e7f97bb88 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -43,6 +43,7 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (expression->initrd
+            %base-initrd-modules
             raw-initrd
             file-system-packages
             base-initrd))
@@ -277,14 +278,31 @@ FILE-SYSTEMS."
   (append-map (compose file-system-type-modules file-system-type)
               file-systems))
 
+(define* (default-initrd-modules #:optional (system (%current-system)))
+  "Return the list of modules included in the initrd by default."
+  `("ahci"                                  ;for SATA controllers
+    "usb-storage" "uas"                     ;for the installation image etc.
+    "usbhid" "hid-generic" "hid-apple"      ;keyboards during early boot
+    "dm-crypt" "xts" "serpent_generic" "wp512" ;for encrypted root partitions
+    "nls_iso8859-1"                            ;for `mkfs.fat`, et.al
+    ,@(if (string-match "^(x86_64|i[3-6]86)-" system)
+          '("pata_acpi" "pata_atiixp"    ;for ATA controllers
+            "isci")                      ;for SAS controllers like Intel C602
+          '())))
+
+(define-syntax %base-initrd-modules
+  ;; This more closely matches our naming convention.
+  (identifier-syntax (default-initrd-modules)))
+
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (linux-modules '())
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
                       (virtio? #t)
-                      (extra-modules '())
+                      (extra-modules '())         ;deprecated
                       (on-error 'debug))
   "Return a monadic derivation that builds a generic initrd, with kernel
 modules taken from LINUX.  FILE-SYSTEMS is a list of file-systems to be
@@ -307,17 +325,9 @@ loaded at boot time in the order in which they appear."
     '("virtio_pci" "virtio_balloon" "virtio_blk" "virtio_net"
       "virtio_console"))
 
-  (define linux-modules
+  (define linux-modules*
     ;; Modules added to the initrd and loaded from the initrd.
-    `("ahci"                                  ;for SATA controllers
-      "usb-storage" "uas"                     ;for the installation image etc.
-      "usbhid" "hid-generic" "hid-apple"      ;keyboards during early boot
-      "dm-crypt" "xts" "serpent_generic" "wp512" ;for encrypted root partitions
-      "nls_iso8859-1"                            ;for `mkfs.fat`, et.al
-      ,@(if (string-match "^(x86_64|i[3-6]86)-" (%current-system))
-            '("pata_acpi" "pata_atiixp"    ;for ATA controllers
-              "isci")                      ;for SAS controllers like Intel C602
-            '())
+    `(,@linux-modules
       ,@(if (or virtio? qemu-networking?)
             virtio-modules
             '())
@@ -332,7 +342,7 @@ loaded at boot time in the order in which they appear."
 
   (raw-initrd file-systems
               #:linux linux
-              #:linux-modules linux-modules
+              #:linux-modules linux-modules*
               #:mapped-devices mapped-devices
               #:helper-packages helper-packages
               #:qemu-networking? qemu-networking?
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index 3ac4a579d..e3bb1b46a 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -565,11 +565,10 @@ where /gnu lives on a separate partition.")
                  (bootloader grub-bootloader)
                  (target "/dev/vdb")))
     (kernel-arguments '("console=ttyS0"))
-    (initrd (lambda (file-systems . rest)
-              ;; Add a kernel module for RAID-0 (aka. "stripe").
-              (apply base-initrd file-systems
-                     #:extra-modules '("raid0")
-                     rest)))
+
+    ;; Add a kernel module for RAID-0 (aka. "stripe").
+    (initrd-modules (cons "raid0" %base-initrd-modules))
+
     (mapped-devices (list (mapped-device
                            (source (list "/dev/vda2" "/dev/vda3"))
                            (target "/dev/md0")
-- 
2.16.2

  parent reply	other threads:[~2018-02-27 14:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 14:17 [bug#30629] [PATCH 0/5] Detect missing modules in the initrd Ludovic Courtès
2018-02-27 14:22 ` Ludovic Courtès
2018-02-27 14:22   ` [bug#30629] [PATCH 1/5] Add (guix glob) Ludovic Courtès
2018-02-27 21:45     ` Marius Bakke
2018-02-28 11:25     ` Danny Milosavljevic
2018-03-01  9:57       ` Ludovic Courtès
2018-03-01 10:11         ` Danny Milosavljevic
2018-03-01 14:29     ` Danny Milosavljevic
2018-02-27 14:22   ` [bug#30629] [PATCH 2/5] linux-modules: Add 'device-module-aliases' and related procedures Ludovic Courtès
2018-02-27 19:33     ` Danny Milosavljevic
2018-02-27 20:55       ` Ludovic Courtès
2018-02-27 21:58         ` Danny Milosavljevic
2018-02-27 21:24           ` Ludovic Courtès
2018-02-27 14:22   ` [bug#30629] [PATCH 3/5] linux-initrd: Separate file system module logic Ludovic Courtès
2018-03-01 14:31     ` Danny Milosavljevic
2018-02-27 14:22   ` Ludovic Courtès [this message]
2018-03-01 18:39     ` [bug#30629] [PATCH 4/5] system: Add 'initrd-modules' field Danny Milosavljevic
2018-02-27 14:22   ` [bug#30629] [PATCH 5/5] guix system: Check for the lack of modules in the initrd Ludovic Courtès
2018-03-02 12:39     ` Danny Milosavljevic
2018-02-27 21:29 ` [bug#30629] [PATCH 0/5] Detect missing " Danny Milosavljevic
2018-02-27 21:15   ` Ludovic Courtès
2018-02-27 22:50     ` Danny Milosavljevic
2018-02-27 23:13       ` [bug#30638] [WIP v2] linux-initrd: Make modprobe pure-Guile Danny Milosavljevic
2018-02-27 23:17         ` Danny Milosavljevic
2018-02-28 11:47         ` [bug#30638] [WIP v3] " Danny Milosavljevic
2018-02-28 12:05           ` [bug#30638] [WIP v4] " Danny Milosavljevic
2018-02-28 11:36       ` [bug#30629] [PATCH 0/5] Detect missing modules in the initrd Danny Milosavljevic
2018-03-01 10:05       ` Ludovic Courtès
2018-03-01 10:11         ` Danny Milosavljevic
2018-03-01 11:46       ` Danny Milosavljevic
2018-03-01 13:39         ` Ludovic Courtès
2018-03-01 13:54           ` Danny Milosavljevic
2018-03-02 12:56             ` bug#30629: " Ludovic Courtès
2018-03-02 17:50               ` [bug#30629] " Danny Milosavljevic
2018-03-02 18:16                 ` Danny Milosavljevic
2018-03-03  8:42                 ` Ludovic Courtès
2018-03-01 13:55           ` Danny Milosavljevic
2018-03-01 21:20             ` Ludovic Courtès
2018-03-02 11:42               ` Danny Milosavljevic
2018-02-28  3:03     ` [bug#30629] Device mapper modalias Danny Milosavljevic
2018-03-01  8:56       ` Danny Milosavljevic
2018-03-01 10:11       ` Ludovic Courtès
2018-03-07 18:56         ` Danny Milosavljevic

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=20180227142245.12674-5-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=30629@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).