summaryrefslogtreecommitdiff
path: root/gnu/system
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-04-18 00:23:16 +0200
committerLudovic Courtès <ludo@gnu.org>2016-04-18 01:24:06 +0200
commitffba7d498d36618ad21af3961a1a685ae91bae57 (patch)
tree5fbd5b0fbf82379ec5a03eaaabc9f8b58192f735 /gnu/system
parent4da8c19e8337cbb908d5e77cd912791846070fb7 (diff)
mapped-devices: LUKS partitions can be designated by their UUID.
* gnu/system/mapped-devices.scm (device-mapping-service-type): Add 'modules' and 'imported-modules' fields to 'shepherd-service'. (open-luks-device): Use 'find-partition-by-luks-uuid' to lookup the partition when SOURCE is a bytevector. * gnu/system/linux-initrd.scm (base-initrd): Augment 'use-modules' form. * doc/guix.texi (Mapped Devices): Give example with a UUID.
Diffstat (limited to 'gnu/system')
-rw-r--r--gnu/system/linux-initrd.scm9
-rw-r--r--gnu/system/mapped-devices.scm29
2 files changed, 33 insertions, 5 deletions
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index aa9fbf6fe98..484bce71c46 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -229,7 +229,14 @@ loaded at boot time in the order in which they appear."
229 (use-modules (gnu build linux-boot) 229 (use-modules (gnu build linux-boot)
230 (guix build utils) 230 (guix build utils)
231 (guix build bournish) ;add the 'bournish' meta-command 231 (guix build bournish) ;add the 'bournish' meta-command
232 (srfi srfi-26)) 232 (srfi srfi-26)
233
234 ;; FIXME: The following modules are for
235 ;; LUKS-DEVICE-MAPPING. We should instead propagate
236 ;; this info via gexps.
237 ((gnu build file-systems)
238 #:select (find-partition-by-luks-uuid))
239 (rnrs bytevectors))
233 240
234 (with-output-to-port (%make-void-port "w") 241 (with-output-to-port (%make-void-port "w")
235 (lambda () 242 (lambda ()
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 2706e255c53..450b4737acc 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -22,6 +22,7 @@
22 #:use-module (gnu services) 22 #:use-module (gnu services)
23 #:use-module (gnu services shepherd) 23 #:use-module (gnu services shepherd)
24 #:autoload (gnu packages cryptsetup) (cryptsetup) 24 #:autoload (gnu packages cryptsetup) (cryptsetup)
25 #:use-module (srfi srfi-1)
25 #:use-module (ice-9 match) 26 #:use-module (ice-9 match)
26 #:export (mapped-device 27 #:export (mapped-device
27 mapped-device? 28 mapped-device?
@@ -77,7 +78,16 @@
77 (documentation "Map a device node using Linux's device mapper.") 78 (documentation "Map a device node using Linux's device mapper.")
78 (start #~(lambda () #$(open source target))) 79 (start #~(lambda () #$(open source target)))
79 (stop #~(lambda _ (not #$(close source target)))) 80 (stop #~(lambda _ (not #$(close source target))))
80 (respawn? #f)))))) 81 (respawn? #f)
82
83 ;; Add the modules needed by LUKS-DEVICE-MAPPING.
84 ;; FIXME: This info should be propagated via gexps.
85 (modules `((rnrs bytevectors) ;bytevector?
86 ((gnu build file-systems)
87 #:select (find-partition-by-luks-uuid))
88 ,@%default-modules))
89 (imported-modules `((gnu build file-systems)
90 ,@%default-imported-modules)))))))
81 91
82(define (device-mapping-service mapped-device) 92(define (device-mapping-service mapped-device)
83 "Return a service that sets up @var{mapped-device}." 93 "Return a service that sets up @var{mapped-device}."
@@ -91,9 +101,20 @@
91(define (open-luks-device source target) 101(define (open-luks-device source target)
92 "Return a gexp that maps SOURCE to TARGET as a LUKS device, using 102 "Return a gexp that maps SOURCE to TARGET as a LUKS device, using
93'cryptsetup'." 103'cryptsetup'."
94 #~(zero? (system* (string-append #$cryptsetup "/sbin/cryptsetup") 104 #~(let ((source #$source))
95 "open" "--type" "luks" 105 (zero? (system* (string-append #$cryptsetup "/sbin/cryptsetup")
96 #$source #$target))) 106 "open" "--type" "luks"
107
108 ;; Note: We cannot use the "UUID=source" syntax here
109 ;; because 'cryptsetup' implements it by searching the
110 ;; udev-populated /dev/disk/by-id directory but udev may
111 ;; be unavailable at the time we run this.
112 (if (bytevector? source)
113 (or (find-partition-by-luks-uuid source)
114 (error "LUKS partition not found" source))
115 source)
116
117 #$target))))
97 118
98(define (close-luks-device source target) 119(define (close-luks-device source target)
99 "Return a gexp that closes TARGET, a LUKS device." 120 "Return a gexp that closes TARGET, a LUKS device."