* [PATCH WIP] linux-initrd: Add a raw-initrd and use it to define base-initrd.
@ 2017-03-07 8:24 Mathieu Othacehe
2017-03-08 17:28 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Othacehe @ 2017-03-07 8:24 UTC (permalink / raw)
To: guix-devel
* gnu/system/linux-initrd.scm (raw-initrd): New exported variable.
(base-initrd): Use raw-initrd to build the initrd.
---
Hi Guix,
Here's a draft patch to provide a raw-initrd. The raw-initrd doesn't try
to guess kernel modules to be included in the initrd.
It has been discussed here :
https://lists.gnu.org/archive/html/guix-devel/2016-07/msg01524.html
and here :
https://lists.gnu.org/archive/html/guix-devel/2017-02/msg00937.html
As a summary, it is useful if you have a custom kernel config and base-initrd tries
to include not compiled modules for example.
raw-initrd doesn't try neither to guess which helper-packages should be included
in the initrd. I'm not sure this is the right thing to do here.
Note I didn't update the doc yet as this is still a draft patch.
What do you think ?
Thank you,
Mathieu
gnu/system/linux-initrd.scm | 128 +++++++++++++++++++++++++++-----------------
1 file changed, 78 insertions(+), 50 deletions(-)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 4a753cdad..a7f916902 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -41,6 +41,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (expression->initrd
+ raw-initrd
base-initrd))
\f
@@ -131,13 +132,79 @@ MODULES and taken from LINUX."
(gexp->derivation "linux-modules" build-exp))
+(define* (raw-initrd file-systems
+ #:key
+ (linux linux-libre)
+ (linux-modules '())
+ (mapped-devices '())
+ (helper-packages '())
+ qemu-networking?
+ volatile-root?)
+ "Return a monadic derivation that builds a raw initrd, with kernel
+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
+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
+mappings to realize before FILE-SYSTEMS are mounted.
+HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include
+e2fsck/static or other packages needed by the initrd to check root partition.
+
+When QEMU-NETWORKING? is true, set up networking with the standard QEMU
+parameters.
+When VOLATILE-ROOT? is true, the root file system is writable but any changes
+to it are lost."
+ (define device-mapping-commands
+ ;; List of gexps to open the mapped devices.
+ (map (lambda (md)
+ (let* ((source (mapped-device-source md))
+ (target (mapped-device-target md))
+ (type (mapped-device-type md))
+ (open (mapped-device-kind-open type)))
+ (open source target)))
+ mapped-devices))
+
+ (mlet %store-monad ((kodir (flat-linux-module-directory linux
+ linux-modules)))
+ (expression->initrd
+ (with-imported-modules (source-module-closure
+ '((gnu build linux-boot)
+ (guix build utils)
+ (guix build bournish)
+ (gnu build file-systems)))
+ #~(begin
+ (use-modules (gnu build linux-boot)
+ (guix build utils)
+ (guix build bournish) ;add the 'bournish' meta-command
+ (srfi srfi-26)
+
+ ;; FIXME: The following modules are for
+ ;; LUKS-DEVICE-MAPPING. We should instead propagate
+ ;; this info via gexps.
+ ((gnu build file-systems)
+ #:select (find-partition-by-luks-uuid))
+ (rnrs bytevectors))
+
+ (with-output-to-port (%make-void-port "w")
+ (lambda ()
+ (set-path-environment-variable "PATH" '("bin" "sbin")
+ '#$helper-packages)))
+
+ (boot-system #:mounts '#$(map file-system->spec file-systems)
+ #:pre-mount (lambda ()
+ (and #$@device-mapping-commands))
+ #:linux-modules '#$linux-modules
+ #:linux-module-directory '#$kodir
+ #:qemu-guest-networking? #$qemu-networking?
+ #:volatile-root? '#$volatile-root?)))
+ #:name "raw-initrd")))
+
(define* (base-initrd file-systems
#:key
(linux linux-libre)
(mapped-devices '())
qemu-networking?
- (virtio? #t)
volatile-root?
+ (virtio? #t)
(extra-modules '()))
"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
@@ -145,14 +212,12 @@ 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
mappings to realize before FILE-SYSTEMS are mounted.
-When QEMU-NETWORKING? is true, set up networking with the standard QEMU
-parameters. When VIRTIO? is true, load additional modules so the initrd can
+QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd.
+
+When VIRTIO? is true, load additional modules so the initrd can
be used as a QEMU guest with the root file system on a para-virtualized block
device.
-When VOLATILE-ROOT? is true, the root file system is writable but any changes
-to it are lost.
-
The initrd is automatically populated with all the kernel modules necessary
for FILE-SYSTEMS and for the given options. However, additional kernel
modules can be listed in EXTRA-MODULES. They will be added to the initrd, and
@@ -224,49 +289,12 @@ loaded at boot time in the order in which they appear."
(list unionfs-fuse/static)
'())))
- (define device-mapping-commands
- ;; List of gexps to open the mapped devices.
- (map (lambda (md)
- (let* ((source (mapped-device-source md))
- (target (mapped-device-target md))
- (type (mapped-device-type md))
- (open (mapped-device-kind-open type)))
- (open source target)))
- mapped-devices))
-
- (mlet %store-monad ((kodir (flat-linux-module-directory linux
- linux-modules)))
- (expression->initrd
- (with-imported-modules (source-module-closure
- '((gnu build linux-boot)
- (guix build utils)
- (guix build bournish)
- (gnu build file-systems)))
- #~(begin
- (use-modules (gnu build linux-boot)
- (guix build utils)
- (guix build bournish) ;add the 'bournish' meta-command
- (srfi srfi-26)
-
- ;; FIXME: The following modules are for
- ;; LUKS-DEVICE-MAPPING. We should instead propagate
- ;; this info via gexps.
- ((gnu build file-systems)
- #:select (find-partition-by-luks-uuid))
- (rnrs bytevectors))
-
- (with-output-to-port (%make-void-port "w")
- (lambda ()
- (set-path-environment-variable "PATH" '("bin" "sbin")
- '#$helper-packages)))
-
- (boot-system #:mounts '#$(map file-system->spec file-systems)
- #:pre-mount (lambda ()
- (and #$@device-mapping-commands))
- #:linux-modules '#$linux-modules
- #:linux-module-directory '#$kodir
- #:qemu-guest-networking? #$qemu-networking?
- #:volatile-root? '#$volatile-root?)))
- #:name "base-initrd")))
+ (raw-initrd file-systems
+ #:linux linux
+ #:linux-modules linux-modules
+ #:mapped-devices mapped-devices
+ #:helper-packages helper-packages
+ #:qemu-networking? qemu-networking?
+ #:volatile-root? volatile-root?))
;;; linux-initrd.scm ends here
--
2.12.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH WIP] linux-initrd: Add a raw-initrd and use it to define base-initrd.
2017-03-07 8:24 [PATCH WIP] linux-initrd: Add a raw-initrd and use it to define base-initrd Mathieu Othacehe
@ 2017-03-08 17:28 ` Ludovic Courtès
2017-03-09 18:39 ` [PATCH] " Mathieu Othacehe
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-03-08 17:28 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: guix-devel
Hi Mathieu,
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
> * gnu/system/linux-initrd.scm (raw-initrd): New exported variable.
> (base-initrd): Use raw-initrd to build the initrd.
Nice!
> It has been discussed here :
> https://lists.gnu.org/archive/html/guix-devel/2016-07/msg01524.html
> and here :
> https://lists.gnu.org/archive/html/guix-devel/2017-02/msg00937.html
>
> As a summary, it is useful if you have a custom kernel config and base-initrd tries
> to include not compiled modules for example.
>
> raw-initrd doesn't try neither to guess which helper-packages should be included
> in the initrd. I'm not sure this is the right thing to do here.
>
> Note I didn't update the doc yet as this is still a draft patch.
>
> What do you think ?
I think it looks good, and definitely an improvement.
So the remaining bits would be:
1. Making sure ‘make check-system TESTS=basic’ or similar works.
2. Adding a copyright line for you. :-)
3. Updating the doc.
Could you send an updated patch?
Thanks for working on it!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] linux-initrd: Add a raw-initrd and use it to define base-initrd.
2017-03-08 17:28 ` Ludovic Courtès
@ 2017-03-09 18:39 ` Mathieu Othacehe
2017-03-10 16:03 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Othacehe @ 2017-03-09 18:39 UTC (permalink / raw)
To: guix-devel
* gnu/system/linux-initrd.scm (raw-initrd): New exported variable.
(base-initrd): Use raw-initrd to build the initrd.
* doc/guix.texi (Initial RAM Disk): Document it.
---
Hi Ludo,
Here's the update, thank for the review !
I run make check-system TESTS=basic like you suggested,
no problems reported.
Thanks,
Mathieu
doc/guix.texi | 47 +++++++++++-----
gnu/system/linux-initrd.scm | 129 +++++++++++++++++++++++++++-----------------
2 files changed, 114 insertions(+), 62 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 49e8d00ea..689093692 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13853,9 +13853,9 @@ kernel modules that may be needed to achieve that.
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 two ways to build an initrd: the
-high-level @code{base-initrd} procedure, and the low-level
-@code{expression->initrd} procedure.
+system linux-initrd)} module provides three ways to build an initrd: the
+high-level @code{base-initrd} procedure and the low-level
+@code{raw-initrd} and @code{expression->initrd} procedures.
The @code{base-initrd} procedure is intended to cover most common uses.
For example, if you want to add a bunch of kernel modules to be loaded
@@ -13876,9 +13876,16 @@ The @code{base-initrd} procedure also handles common use cases that
involves using the system as a QEMU guest, or as a ``live'' system with
volatile root file system.
-The initial RAM disk produced by @code{base-initrd} honors several
-options passed on the Linux kernel command line (that is, arguments
-passed @i{via} the @code{linux} command of GRUB, or the
+The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
+Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
+such as trying to guess which kernel modules and packages should be included
+to the initrd. An example use of @code{raw-initrd} is when a user has
+a custom Linux kernel configuration and default kernel modules included by
+@code{base-initrd} are not available.
+
+The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
+honors several options passed on the Linux kernel command line
+(that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
@code{-append} option of QEMU), notably:
@table @code
@@ -13917,19 +13924,23 @@ Manual}, for more information on Guile's REPL.
@end table
Now that you know all the features that initial RAM disks produced by
-@code{base-initrd} provide, here is how to use it and customize it
-further.
+@code{base-initrd} and @code{raw-initrd} provide,
+here is how to use it and customize it further.
@cindex initrd
@cindex initial RAM disk
-@deffn {Monadic Procedure} base-initrd @var{file-systems} @
- [#:qemu-networking? #f] [#:virtio? #t] [#:volatile-root? #f] @
- [#:extra-modules '()] [#:mapped-devices '()]
-Return a monadic derivation that builds a generic initrd. @var{file-systems} is
+@deffn {Monadic Procedure} raw-initrd @var{file-systems} @
+ [#:linux-modules '()] [#:mapped-devices '()] @
+ [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
+Return a monadic 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
the root file system specified on the kernel command line via @code{--root}.
+@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{file-systems} are mounted (@pxref{Mapped Devices}).
+@var{helper-packages} is a list of packages to be copied in the initrd. It may
+include @code{e2fsck/static} or other packages needed by the initrd to check
+root partition.
When @var{qemu-networking?} is true, set up networking with the standard QEMU
parameters. When @var{virtio?} is true, load additional modules so that the
@@ -13937,6 +13948,18 @@ initrd can be used as a QEMU guest with para-virtualized I/O drivers.
When @var{volatile-root?} is true, the root file system is writable but any changes
to it are lost.
+@end deffn
+
+@deffn {Monadic Procedure} base-initrd @var{file-systems} @
+ [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
+ [#:virtio? #t] [#:extra-modules '()]
+Return a monadic derivation that builds a generic initrd. @var{file-systems} is
+a list of file systems to be mounted by the initrd like for @code{raw-initrd}.
+@var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?}
+also behaves as in @code{raw-initrd}.
+
+When @var{virtio?} is true, load additional modules so that the
+initrd can be used as a QEMU guest with para-virtualized I/O drivers.
The initrd is automatically populated with all the kernel modules necessary
for @var{file-systems} and for the given options. However, additional kernel
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 4a753cdad..81c1278c0 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -41,6 +42,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (expression->initrd
+ raw-initrd
base-initrd))
\f
@@ -131,13 +133,79 @@ MODULES and taken from LINUX."
(gexp->derivation "linux-modules" build-exp))
+(define* (raw-initrd file-systems
+ #:key
+ (linux linux-libre)
+ (linux-modules '())
+ (mapped-devices '())
+ (helper-packages '())
+ qemu-networking?
+ volatile-root?)
+ "Return a monadic derivation that builds a raw initrd, with kernel
+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
+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
+mappings to realize before FILE-SYSTEMS are mounted.
+HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include
+e2fsck/static or other packages needed by the initrd to check root partition.
+
+When QEMU-NETWORKING? is true, set up networking with the standard QEMU
+parameters.
+When VOLATILE-ROOT? is true, the root file system is writable but any changes
+to it are lost."
+ (define device-mapping-commands
+ ;; List of gexps to open the mapped devices.
+ (map (lambda (md)
+ (let* ((source (mapped-device-source md))
+ (target (mapped-device-target md))
+ (type (mapped-device-type md))
+ (open (mapped-device-kind-open type)))
+ (open source target)))
+ mapped-devices))
+
+ (mlet %store-monad ((kodir (flat-linux-module-directory linux
+ linux-modules)))
+ (expression->initrd
+ (with-imported-modules (source-module-closure
+ '((gnu build linux-boot)
+ (guix build utils)
+ (guix build bournish)
+ (gnu build file-systems)))
+ #~(begin
+ (use-modules (gnu build linux-boot)
+ (guix build utils)
+ (guix build bournish) ;add the 'bournish' meta-command
+ (srfi srfi-26)
+
+ ;; FIXME: The following modules are for
+ ;; LUKS-DEVICE-MAPPING. We should instead propagate
+ ;; this info via gexps.
+ ((gnu build file-systems)
+ #:select (find-partition-by-luks-uuid))
+ (rnrs bytevectors))
+
+ (with-output-to-port (%make-void-port "w")
+ (lambda ()
+ (set-path-environment-variable "PATH" '("bin" "sbin")
+ '#$helper-packages)))
+
+ (boot-system #:mounts '#$(map file-system->spec file-systems)
+ #:pre-mount (lambda ()
+ (and #$@device-mapping-commands))
+ #:linux-modules '#$linux-modules
+ #:linux-module-directory '#$kodir
+ #:qemu-guest-networking? #$qemu-networking?
+ #:volatile-root? '#$volatile-root?)))
+ #:name "raw-initrd")))
+
(define* (base-initrd file-systems
#:key
(linux linux-libre)
(mapped-devices '())
qemu-networking?
- (virtio? #t)
volatile-root?
+ (virtio? #t)
(extra-modules '()))
"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
@@ -145,14 +213,12 @@ 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
mappings to realize before FILE-SYSTEMS are mounted.
-When QEMU-NETWORKING? is true, set up networking with the standard QEMU
-parameters. When VIRTIO? is true, load additional modules so the initrd can
+QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd.
+
+When VIRTIO? is true, load additional modules so the initrd can
be used as a QEMU guest with the root file system on a para-virtualized block
device.
-When VOLATILE-ROOT? is true, the root file system is writable but any changes
-to it are lost.
-
The initrd is automatically populated with all the kernel modules necessary
for FILE-SYSTEMS and for the given options. However, additional kernel
modules can be listed in EXTRA-MODULES. They will be added to the initrd, and
@@ -224,49 +290,12 @@ loaded at boot time in the order in which they appear."
(list unionfs-fuse/static)
'())))
- (define device-mapping-commands
- ;; List of gexps to open the mapped devices.
- (map (lambda (md)
- (let* ((source (mapped-device-source md))
- (target (mapped-device-target md))
- (type (mapped-device-type md))
- (open (mapped-device-kind-open type)))
- (open source target)))
- mapped-devices))
-
- (mlet %store-monad ((kodir (flat-linux-module-directory linux
- linux-modules)))
- (expression->initrd
- (with-imported-modules (source-module-closure
- '((gnu build linux-boot)
- (guix build utils)
- (guix build bournish)
- (gnu build file-systems)))
- #~(begin
- (use-modules (gnu build linux-boot)
- (guix build utils)
- (guix build bournish) ;add the 'bournish' meta-command
- (srfi srfi-26)
-
- ;; FIXME: The following modules are for
- ;; LUKS-DEVICE-MAPPING. We should instead propagate
- ;; this info via gexps.
- ((gnu build file-systems)
- #:select (find-partition-by-luks-uuid))
- (rnrs bytevectors))
-
- (with-output-to-port (%make-void-port "w")
- (lambda ()
- (set-path-environment-variable "PATH" '("bin" "sbin")
- '#$helper-packages)))
-
- (boot-system #:mounts '#$(map file-system->spec file-systems)
- #:pre-mount (lambda ()
- (and #$@device-mapping-commands))
- #:linux-modules '#$linux-modules
- #:linux-module-directory '#$kodir
- #:qemu-guest-networking? #$qemu-networking?
- #:volatile-root? '#$volatile-root?)))
- #:name "base-initrd")))
+ (raw-initrd file-systems
+ #:linux linux
+ #:linux-modules linux-modules
+ #:mapped-devices mapped-devices
+ #:helper-packages helper-packages
+ #:qemu-networking? qemu-networking?
+ #:volatile-root? volatile-root?))
;;; linux-initrd.scm ends here
--
2.12.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] linux-initrd: Add a raw-initrd and use it to define base-initrd.
2017-03-09 18:39 ` [PATCH] " Mathieu Othacehe
@ 2017-03-10 16:03 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-03-10 16:03 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: guix-devel
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
> * gnu/system/linux-initrd.scm (raw-initrd): New exported variable.
> (base-initrd): Use raw-initrd to build the initrd.
> * doc/guix.texi (Initial RAM Disk): Document it.
> ---
>
> Hi Ludo,
>
> Here's the update, thank for the review !
> I run make check-system TESTS=basic like you suggested,
> no problems reported.
Great. Applied, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-10 16:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07 8:24 [PATCH WIP] linux-initrd: Add a raw-initrd and use it to define base-initrd Mathieu Othacehe
2017-03-08 17:28 ` Ludovic Courtès
2017-03-09 18:39 ` [PATCH] " Mathieu Othacehe
2017-03-10 16:03 ` Ludovic Courtès
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).