From de1c158f32e1d4060daa600a62b68fe22b613424 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 22 Sep 2014 11:06:42 +0200 Subject: system: Add support for boot-time mapped devices. * gnu/build/linux-boot.scm (boot-system): Add #:pre-mount parameter and honor it. * gnu/system/linux-initrd.scm (base-initrd): Add #:mapped-devices parameter. Add 'device-mapping-commands' variable, and use it to build the #:pre-mount argument of 'boot-system'. * gnu/system.scm (mapped-device-user, operating-system-user-mapped-devices, operating-system-boot-mapped-devices): New procedures. (device-mapping-services): Use 'operating-system-user-mapped-devices' instead of 'operating-system-mapped-devices'. (operating-system-initrd-file): Call the initrd with #:mapped-devices. --- gnu/system/linux-initrd.scm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gnu/system') diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index cb04644053..d1b1216f9d 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -126,14 +126,16 @@ initrd code." (define* (base-initrd file-systems #:key + (mapped-devices '()) qemu-networking? virtio? volatile-root? (extra-modules '())) - ;; TODO: Support boot-time device mappings. "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. When QEMU-NETWORKING? is true, set up networking with the standard QEMU parameters. When VIRTIO? is true, load additional modules so the initrd can @@ -191,6 +193,16 @@ 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-libre linux-modules))) (expression->initrd @@ -205,6 +217,8 @@ loaded at boot time in the order in which they appear." '#$helper-packages))) (boot-system #:mounts '#$(map file-system->spec file-systems) + #:pre-mount (lambda () + (and #$@device-mapping-commands)) #:linux-modules (map (lambda (file) (string-append #$kodir "/" file)) '#$linux-modules) -- cgit v1.2.3