linux-initrd: Store Linux modules in a normal store directory.

* gnu/system/linux-initrd.scm (expression->initrd): Remove #:linux and
  #:linux-modules parameters.  Remove call to
  'float-linux-module-directory'.
  (base-initrd): Add call to 'float-linux-module-directory'.  Use it in
  #:linux-modules argument in the gexp.  Remove #:linux and
  #:linux-modules arguments to 'expression->initrd'.
* gnu/build/linux-initrd.scm (build-initrd): Remove
  #:linux-module-directory parameter.  Don't create 'modules'
  sub-directory.
* gnu/build/linux-boot.scm (boot-system): Mentin that LINUX-MODULES is a
  list of absolute file names.  Don't prepend "/modules/" to
  LINUX-MODULES.
* doc/guix.texi (Initial RAM Disk): Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2014-09-08 23:46:48 +02:00
parent df650fa84e
commit 42d10464be
4 changed files with 39 additions and 50 deletions

View file

@ -3616,16 +3616,14 @@ program to run in that initrd.
@deffn {Monadic Procedure} expression->initrd @var{exp} @
[#:guile %guile-static-stripped] [#:name "guile-initrd"] @
[#:modules '()] [#:linux #f] @
[#:linux-modules '()]
[#:modules '()]
Return a derivation that builds a Linux initrd (a gzipped cpio archive)
containing @var{guile} and that evaluates @var{exp}, a G-expression,
upon booting. All the derivations referenced by @var{exp} are
automatically copied to the initrd.
@var{linux-modules} is a list of @file{.ko} file names to be copied from
@var{linux} into the initrd. @var{modules} is a list of Guile module
names to be embedded in the initrd.
@var{modules} is a list of Guile module names to be embedded in the
initrd.
@end deffn
@node Invoking guix system

View file

@ -343,10 +343,11 @@ (define* (boot-system #:key
volatile-root?
(mounts '()))
"This procedure is meant to be called from an initrd. Boot a system by
first loading LINUX-MODULES, then setting up QEMU guest networking if
QEMU-GUEST-NETWORKING? is true, mounting the file systems specified in MOUNTS,
and finally booting into the new root if any. The initrd supports kernel
command-line options '--load', '--root', and '--repl'.
first loading LINUX-MODULES (a list of absolute file names of '.ko' files),
then setting up QEMU guest networking if QEMU-GUEST-NETWORKING? is true,
mounting the file systems specified in MOUNTS, and finally booting into the
new root if any. The initrd supports kernel command-line options '--load',
'--root', and '--repl'.
Mount the root file system, specified by the '--root' command-line argument,
if any.
@ -384,9 +385,7 @@ (define root-fs-type
(start-repl))
(display "loading kernel modules...\n")
(for-each (compose load-linux-module*
(cut string-append "/modules/" <>))
linux-modules)
(for-each load-linux-module* linux-modules)
(when qemu-guest-networking?
(unless (configure-qemu-networking)

View file

@ -104,23 +104,18 @@ (define (compile-to-cache file)
(define* (build-initrd output
#:key
guile init
linux-module-directory
(references-graphs '())
(cpio "cpio")
(gzip "gzip"))
"Write an initial RAM disk (initrd) to OUTPUT. The initrd starts the script
at INIT, running GUILE. It contains all the items referred to by
REFERENCES-GRAPHS, plus the Linux modules from LINUX-MODULE-DIRECTORY."
REFERENCES-GRAPHS."
(mkdir "contents")
;; Copy the closures of all the items referenced in REFERENCES-GRAPHS.
(populate-store references-graphs "contents")
(with-directory-excursion "contents"
;; Copy Linux modules.
(mkdir "modules")
(copy-recursively linux-module-directory "modules")
;; Make '/init'.
(symlink init "init")

View file

@ -34,6 +34,7 @@ (define-module (gnu system linux-initrd)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (expression->initrd
base-initrd))
@ -53,25 +54,19 @@ (define* (expression->initrd exp
(gzip gzip)
(name "guile-initrd")
(system (%current-system))
(modules '())
(linux #f)
(linux-modules '()))
(modules '()))
"Return a derivation that builds a Linux initrd (a gzipped cpio archive)
containing GUILE and that evaluates EXP, a G-expression, upon booting. All
the derivations referenced by EXP are automatically copied to the initrd.
LINUX-MODULES is a list of '.ko' file names to be copied from LINUX into the
initrd. MODULES is a list of Guile module names to be embedded in the
initrd."
MODULES is a list of Guile module names to be embedded in the initrd."
;; General Linux overview in `Documentation/early-userspace/README' and
;; `Documentation/filesystems/ramfs-rootfs-initramfs.txt'.
(mlet* %store-monad ((init (gexp->script "init" exp
#:modules modules
#:guile guile))
(module-dir (flat-linux-module-directory linux
linux-modules)))
(mlet %store-monad ((init (gexp->script "init" exp
#:modules modules
#:guile guile)))
(define builder
#~(begin
(use-modules (gnu build linux-initrd))
@ -80,8 +75,8 @@ (define builder
(build-initrd (string-append #$output "/initrd")
#:guile #$guile
#:init #$init
;; Copy everything INIT refers to into the initrd.
#:references-graphs '("closure")
#:linux-module-directory #$module-dir
#:cpio (string-append #$cpio "/bin/cpio")
#:gzip (string-append #$gzip "/bin/gzip"))))
@ -201,27 +196,29 @@ (define helper-packages
(list unionfs-fuse/static)
'())))
(expression->initrd
#~(begin
(use-modules (gnu build linux-boot)
(guix build utils)
(srfi srfi-26))
(mlet %store-monad ((kodir (flat-linux-module-directory linux-libre
linux-modules)))
(expression->initrd
#~(begin
(use-modules (gnu build linux-boot)
(guix build utils)
(srfi srfi-26))
(with-output-to-port (%make-void-port "w")
(lambda ()
(set-path-environment-variable "PATH" '("bin" "sbin")
'#$helper-packages)))
(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)
#:linux-modules '#$linux-modules
#:qemu-guest-networking? #$qemu-networking?
#:guile-modules-in-chroot? '#$guile-modules-in-chroot?
#:volatile-root? '#$volatile-root?))
#:name "base-initrd"
#:modules '((guix build utils)
(gnu build linux-boot)
(gnu build file-systems))
#:linux linux-libre
#:linux-modules linux-modules))
(boot-system #:mounts '#$(map file-system->spec file-systems)
#:linux-modules (map (lambda (file)
(string-append #$kodir "/" file))
'#$linux-modules)
#:qemu-guest-networking? #$qemu-networking?
#:guile-modules-in-chroot? '#$guile-modules-in-chroot?
#:volatile-root? '#$volatile-root?))
#:name "base-initrd"
#:modules '((guix build utils)
(gnu build linux-boot)
(gnu build file-systems)))))
;;; linux-initrd.scm ends here