summaryrefslogtreecommitdiff
path: root/gnu/system
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/system')
-rw-r--r--gnu/system/linux-initrd.scm1
-rw-r--r--gnu/system/mapped-devices.scm25
2 files changed, 24 insertions, 2 deletions
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 3e2f1282ccc..85e493fecb9 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -217,6 +217,7 @@ upon error."
217 (gnu system file-systems) 217 (gnu system file-systems)
218 ((guix build utils) #:hide (delete)) 218 ((guix build utils) #:hide (delete))
219 (guix build bournish) ;add the 'bournish' meta-command 219 (guix build bournish) ;add the 'bournish' meta-command
220 (srfi srfi-1) ;for lvm-device-mapping
220 (srfi srfi-26) 221 (srfi srfi-26)
221 222
222 ;; FIXME: The following modules are for 223 ;; FIXME: The following modules are for
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 8b5aec983d1..559c27bb28c 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -36,7 +36,7 @@
36 #:autoload (gnu build linux-modules) 36 #:autoload (gnu build linux-modules)
37 (missing-modules) 37 (missing-modules)
38 #:autoload (gnu packages cryptsetup) (cryptsetup-static) 38 #:autoload (gnu packages cryptsetup) (cryptsetup-static)
39 #:autoload (gnu packages linux) (mdadm-static) 39 #:autoload (gnu packages linux) (mdadm-static lvm2-static)
40 #:use-module (srfi srfi-1) 40 #:use-module (srfi srfi-1)
41 #:use-module (srfi srfi-26) 41 #:use-module (srfi srfi-26)
42 #:use-module (srfi srfi-34) 42 #:use-module (srfi srfi-34)
@@ -64,7 +64,8 @@
64 check-device-initrd-modules ;XXX: needs a better place 64 check-device-initrd-modules ;XXX: needs a better place
65 65
66 luks-device-mapping 66 luks-device-mapping
67 raid-device-mapping)) 67 raid-device-mapping
68 lvm-device-mapping))
68 69
69;;; Commentary: 70;;; Commentary:
70;;; 71;;;
@@ -304,4 +305,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
304 (open open-raid-device) 305 (open open-raid-device)
305 (close close-raid-device))) 306 (close close-raid-device)))
306 307
308(define (open-lvm-device source targets)
309 #~(and
310 (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
311 "vgchange" "--activate" "ay" #$source))
312 ; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here.
313 (zero? (system* #$(file-append lvm2-static "/sbin/lvm")
314 "vgscan" "--mknodes"))
315 (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file))
316 '#$targets))))
317
318
319(define (close-lvm-device source targets)
320 #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm")
321 "vgchange" "--activate" "n" #$source)))
322
323(define lvm-device-mapping
324 (mapped-device-kind
325 (open open-lvm-device)
326 (close close-lvm-device)))
327
307;;; mapped-devices.scm ends here 328;;; mapped-devices.scm ends here