diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-02-27 14:55:43 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-03-02 13:53:15 +0100 |
| commit | 424cea8083a4cee63290c80235aed61bd12affb1 (patch) | |
| tree | b588b7552e1bcfa83f6304aa6c9d0215c6ee7b75 /gnu/system | |
| parent | bc499b113a598c0e7863da9887a4133472985713 (diff) | |
guix system: Check for the lack of modules in the initrd.
* guix/scripts/system.scm (check-mapped-devices): Take an OS instead of
a list of <mapped-device>. Pass #:needed-for-boot? and #:initrd-modules
to CHECK.
(check-initrd-modules): New procedure.
(perform-action): Move 'check-mapped-devices' call first. Add call to
'check-initrd-modules'.
* gnu/system/mapped-devices.scm (check-device-initrd-modules): New
procedure.
(check-luks-device): Add #:initrd-modules and #:needed-for-boot?. Use
them to call 'check-device-initrd-modules'.
Diffstat (limited to 'gnu/system')
| -rw-r--r-- | gnu/system/mapped-devices.scm | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index dbeb0d34364..5ceb5e658cb 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr> | 3 | ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr> |
| 4 | ;;; Copyright © 2017 Mark H Weaver <mhw@netris.org> | 4 | ;;; Copyright © 2017 Mark H Weaver <mhw@netris.org> |
| 5 | ;;; | 5 | ;;; |
| @@ -30,9 +30,12 @@ | |||
| 30 | #:use-module (gnu services shepherd) | 30 | #:use-module (gnu services shepherd) |
| 31 | #:use-module (gnu system uuid) | 31 | #:use-module (gnu system uuid) |
| 32 | #:autoload (gnu build file-systems) (find-partition-by-luks-uuid) | 32 | #:autoload (gnu build file-systems) (find-partition-by-luks-uuid) |
| 33 | #:autoload (gnu build linux-modules) | ||
| 34 | (device-module-aliases matching-modules) | ||
| 33 | #:autoload (gnu packages cryptsetup) (cryptsetup-static) | 35 | #:autoload (gnu packages cryptsetup) (cryptsetup-static) |
| 34 | #:autoload (gnu packages linux) (mdadm-static) | 36 | #:autoload (gnu packages linux) (mdadm-static) |
| 35 | #:use-module (srfi srfi-1) | 37 | #:use-module (srfi srfi-1) |
| 38 | #:use-module (srfi srfi-26) | ||
| 36 | #:use-module (srfi srfi-34) | 39 | #:use-module (srfi srfi-34) |
| 37 | #:use-module (srfi srfi-35) | 40 | #:use-module (srfi srfi-35) |
| 38 | #:use-module (ice-9 match) | 41 | #:use-module (ice-9 match) |
| @@ -151,19 +154,43 @@ | |||
| 151 | #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") | 154 | #~(zero? (system* #$(file-append cryptsetup-static "/sbin/cryptsetup") |
| 152 | "close" #$target))) | 155 | "close" #$target))) |
| 153 | 156 | ||
| 154 | (define (check-luks-device md) | 157 | (define (check-device-initrd-modules device linux-modules location) |
| 158 | "Raise an error if DEVICE needs modules beyond LINUX-MODULES to operate. | ||
| 159 | DEVICE must be a \"/dev\" file name." | ||
| 160 | (let ((modules (delete-duplicates | ||
| 161 | (append-map matching-modules | ||
| 162 | (device-module-aliases device))))) | ||
| 163 | (unless (every (cute member <> linux-modules) modules) | ||
| 164 | (raise (condition | ||
| 165 | (&message | ||
| 166 | (message (format #f (G_ "you may need these modules \ | ||
| 167 | in the initrd for ~a:~{ ~a~}") | ||
| 168 | device modules))) | ||
| 169 | (&error-location | ||
| 170 | (location (source-properties->location location)))))))) | ||
| 171 | |||
| 172 | (define* (check-luks-device md #:key | ||
| 173 | needed-for-boot? | ||
| 174 | (initrd-modules '()) | ||
| 175 | #:allow-other-keys | ||
| 176 | #:rest rest) | ||
| 155 | "Ensure the source of MD is valid." | 177 | "Ensure the source of MD is valid." |
| 156 | (let ((source (mapped-device-source md))) | 178 | (let ((source (mapped-device-source md)) |
| 157 | (or (not (uuid? source)) | 179 | (location (mapped-device-location md))) |
| 158 | (not (zero? (getuid))) | 180 | (or (not (zero? (getuid))) |
| 159 | (find-partition-by-luks-uuid (uuid-bytevector source)) | 181 | (if (uuid? source) |
| 160 | (raise (condition | 182 | (match (find-partition-by-luks-uuid (uuid-bytevector source)) |
| 161 | (&message | 183 | (#f |
| 162 | (message (format #f (G_ "no LUKS partition with UUID '~a'") | 184 | (raise (condition |
| 163 | (uuid->string source)))) | 185 | (&message |
| 164 | (&error-location | 186 | (message (format #f (G_ "no LUKS partition with UUID '~a'") |
| 165 | (location (source-properties->location | 187 | (uuid->string source)))) |
| 166 | (mapped-device-location md))))))))) | 188 | (&error-location |
| 189 | (location (source-properties->location | ||
| 190 | (mapped-device-location md))))))) | ||
| 191 | ((? string? device) | ||
| 192 | (check-device-initrd-modules device initrd-modules location))) | ||
| 193 | (check-device-initrd-modules source initrd-modules location))))) | ||
| 167 | 194 | ||
| 168 | (define luks-device-mapping | 195 | (define luks-device-mapping |
| 169 | ;; The type of LUKS mapped devices. | 196 | ;; The type of LUKS mapped devices. |
