mapped-devices: Add 'lvm-device-mapping'.

* gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device,
close-lvm-device): New variables.

* gnu/tests/install.scm (%lvm-separate-home-os,
%lvm-separate-home-os-source, %lvm-separate-home-installation-script,
%test-lvm-separate-home-os): New variables.

* gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Mikhail Tsykalov 2020-11-06 12:47:38 +03:00 committed by Ludovic Courtès
parent 788df2ecd6
commit a9a2fdaabc
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
4 changed files with 134 additions and 4 deletions

View file

@ -36,7 +36,7 @@
#:autoload (gnu build linux-modules)
(missing-modules)
#:autoload (gnu packages cryptsetup) (cryptsetup-static)
#:autoload (gnu packages linux) (mdadm-static)
#:autoload (gnu packages linux) (mdadm-static lvm2-static)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
@ -64,7 +64,8 @@
check-device-initrd-modules ;XXX: needs a better place
luks-device-mapping
raid-device-mapping))
raid-device-mapping
lvm-device-mapping))
;;; Commentary:
;;;
@ -304,4 +305,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'."
(open open-raid-device)
(close close-raid-device)))
(define (open-lvm-device source targets)
#~(and
(zero? (system* #$(file-append lvm2-static "/sbin/lvm")
"vgchange" "--activate" "ay" #$source))
; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here.
(zero? (system* #$(file-append lvm2-static "/sbin/lvm")
"vgscan" "--mknodes"))
(every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file))
'#$targets))))
(define (close-lvm-device source targets)
#~(zero? (system* #$(file-append lvm2-static "/sbin/lvm")
"vgchange" "--activate" "n" #$source)))
(define lvm-device-mapping
(mapped-device-kind
(open open-lvm-device)
(close close-lvm-device)))
;;; mapped-devices.scm ends here