Next: , Previous: , Up: System Configuration   [Contents][Index]


7.2.11 Initial RAM Disk

For bootstrapping purposes, the Linux-Libre kernel is passed an initial RAM disk, or initrd. An initrd contains a temporary 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 initrd field of an operating-system declaration allows you to specify which initrd you would like to use. The (gnu system linux-initrd) module provides two ways to build an initrd: the high-level base-initrd procedure, and the low-level expression->initrd procedure.

The 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 at boot time, you can define the initrd field of the operating system declaration like this:

(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.
          (apply base-initrd file-systems
                 #:extra-modules '("foo" "bar")
                 rest)))

The base-initrd procedure also handles common use cases that involves using the system as a QEMU guest, or as a “live” system whose root file system is volatile.

Monadic Procedure: base-initrd file-systems [#:qemu-networking? #f] [#:virtio? #f] [#:volatile-root? #f] [#:extra-modules '()] [#:mapped-devices '()]

Return a monadic derivation that builds a generic initrd. 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. mapped-devices is a list of device mappings to realize before file-systems are mounted (see Mapped Devices).

When qemu-networking? is true, set up networking with the standard QEMU parameters. When virtio? is true, load additional modules so the initrd can be used as a QEMU guest with para-virtualized I/O drivers.

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 loaded at boot time in the order in which they appear.

Needless to say, the initrds we produce and use embed a statically-linked Guile, and the initialization program is a Guile program. That gives a lot of flexibility. The expression->initrd procedure builds such an initrd, given the program to run in that initrd.

Monadic Procedure: expression->initrd exp [#:guile %guile-static-stripped] [#:name "guile-initrd"] [#: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.

modules is a list of Guile module names to be embedded in the initrd.


Next: , Previous: , Up: System Configuration   [Contents][Index]