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

View File

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

View File

@ -104,23 +104,18 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
(define* (build-initrd output (define* (build-initrd output
#:key #:key
guile init guile init
linux-module-directory
(references-graphs '()) (references-graphs '())
(cpio "cpio") (cpio "cpio")
(gzip "gzip")) (gzip "gzip"))
"Write an initial RAM disk (initrd) to OUTPUT. The initrd starts the script "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 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") (mkdir "contents")
;; Copy the closures of all the items referenced in REFERENCES-GRAPHS. ;; Copy the closures of all the items referenced in REFERENCES-GRAPHS.
(populate-store references-graphs "contents") (populate-store references-graphs "contents")
(with-directory-excursion "contents" (with-directory-excursion "contents"
;; Copy Linux modules.
(mkdir "modules")
(copy-recursively linux-module-directory "modules")
;; Make '/init'. ;; Make '/init'.
(symlink init "init") (symlink init "init")

View File

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