guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: system: Add mapped devices for RAID.


From: Andreas Enge
Subject: 02/02: system: Add mapped devices for RAID.
Date: Sat, 16 Jul 2016 20:35:17 +0000 (UTC)

andreas pushed a commit to branch wip-hydra
in repository guix.

commit c211853c5d181db73cfb689c43ebfc0c9ac6c6e3
Author: Andreas Enge <address@hidden>
Date:   Thu Jul 14 15:51:59 2016 +0200

    system: Add mapped devices for RAID.
    
    * gnu/system/mapped-devices.scm (raid-device-mapping, open-raid-device,
    close-raid-device): New variables.
---
 gnu/system/mapped-devices.scm |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 732f73c..70ad1c2 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 <address@hidden>
+;;; Copyright © 2016 Andreas Enge <address@hidden>
 ;;;
 ;;; 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,22 @@
    (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'."
+  #~(zero? (system* (string-append #$mdadm "/sbin/mdadm")
+                       "--assemble" #$target
+                       address@hidden)))
+
+(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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]