From 97c8aef15de89799ac01b62dd9b91245c23eefcb Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Thu, 14 Jul 2016 15:51:59 +0200 Subject: system: Add mapped devices for RAID. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/system/mapped-devices.scm (raid-device-mapping, open-raid-device, close-raid-device): New variables. * doc/guix.texi (Mapped Devices): Add documentation for RAID devices, reorganize documentation for LUKS devices. Co-authored-by: Ludovic Courtès --- gnu/system/mapped-devices.scm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'gnu/system') diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 732f73cc4b..d0a9f0288f 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2016 Andreas Enge ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,7 @@ #:use-module (gnu services) #:use-module (gnu services shepherd) #:autoload (gnu packages cryptsetup) (cryptsetup) + #:autoload (gnu packages linux) (mdadm) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (mapped-device @@ -38,7 +40,8 @@ device-mapping-service-type device-mapping-service - luks-device-mapping)) + luks-device-mapping + raid-device-mapping)) ;;; Commentary: ;;; @@ -127,4 +130,28 @@ (open open-luks-device) (close close-luks-device))) +(define (open-raid-device source target) + "Return a gexp that assembles SOURCE (a list of devices) to the RAID device +TARGET, using 'mdadm'." + #~(let ((every (@ (srfi srfi-1) every))) + (let loop () + (unless (every file-exists? '#$source) + (format #t "waiting a bit...~%") + (sleep 1) + (loop))) + (zero? (system* (string-append #$mdadm "/sbin/mdadm") + "--assemble" #$target + #$@source)))) + +(define (close-raid-device source target) + "Return a gexp that stops the RAID device TARGET." + #~(zero? (system* (string-append #$mdadm "/sbin/mdadm") + "--stop" #$target))) + +(define raid-device-mapping + ;; The type of RAID mapped devices. + (mapped-device-kind + (open open-raid-device) + (close close-raid-device))) + ;;; mapped-devices.scm ends here -- cgit 1.4.1