Skip to content
Snippets Groups Projects
Commit f453f637 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

system: Allow the root file system to be named by UUID.

* gnu/build/file-systems.scm (canonicalize-device-spec)[canonical-title]:
Use 'string->uuid' to check whether SPEC is a UUID.
When SPEC is a string and CANONICAL-TITLE is 'uuid, call 'string->uuid'.
* gnu/system.scm (operating-system-grub.cfg): Add 'root-device'
variable and use it for the "--root=" argument.
parent f8865db6
No related branches found
No related tags found
No related merge requests found
...@@ -295,9 +295,12 @@ (define canonical-title ...@@ -295,9 +295,12 @@ (define canonical-title
;; The realm of canonicalization. ;; The realm of canonicalization.
(if (eq? title 'any) (if (eq? title 'any)
(if (string? spec) (if (string? spec)
(if (string-prefix? "/" spec) ;; The "--root=SPEC" kernel command-line option always provides a
'device ;; string, but the string can represent a device, a UUID, or a
'label) ;; label. So check for all three.
(cond ((string-prefix? "/" spec) 'device)
((string->uuid spec) 'uuid)
(else 'label))
'uuid) 'uuid)
title)) title))
...@@ -323,7 +326,11 @@ (define (resolve find-partition spec fmt) ...@@ -323,7 +326,11 @@ (define (resolve find-partition spec fmt)
;; Resolve the label. ;; Resolve the label.
(resolve find-partition-by-label spec identity)) (resolve find-partition-by-label spec identity))
((uuid) ((uuid)
(resolve find-partition-by-uuid spec uuid->string)) (resolve find-partition-by-uuid
(if (string? spec)
(string->uuid spec)
spec)
uuid->string))
(else (else
(error "unknown device title" title)))) (error "unknown device title" title))))
......
...@@ -673,12 +673,14 @@ (define* (operating-system-grub.cfg os #:optional (old-entries '())) ...@@ -673,12 +673,14 @@ (define* (operating-system-grub.cfg os #:optional (old-entries '()))
((system (operating-system-derivation os)) ((system (operating-system-derivation os))
(root-fs -> (operating-system-root-file-system os)) (root-fs -> (operating-system-root-file-system os))
(kernel -> (operating-system-kernel os)) (kernel -> (operating-system-kernel os))
(root-device -> (if (eq? 'uuid (file-system-title root-fs))
(uuid->string (file-system-device root-fs))
(file-system-device root-fs)))
(entries -> (list (menu-entry (entries -> (list (menu-entry
(label (kernel->grub-label kernel)) (label (kernel->grub-label kernel))
(linux kernel) (linux kernel)
(linux-arguments (linux-arguments
(cons* (string-append "--root=" (cons* (string-append "--root=" root-device)
(file-system-device root-fs))
#~(string-append "--system=" #$system) #~(string-append "--system=" #$system)
#~(string-append "--load=" #$system #~(string-append "--load=" #$system
"/boot") "/boot")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment