guix-commits
[Top][All Lists]
Advanced

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

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


From: Ludovic Courtès
Subject: 04/05: system: Allow the root file system to be named by UUID.
Date: Fri, 01 Jan 2016 22:00:37 +0000

civodul pushed a commit to branch master
in repository guix.

commit f453f637d5410f4d1e0b3787caa8d34b9b72d7d8
Author: Ludovic Courtès <address@hidden>
Date:   Fri Jan 1 22:45:58 2016 +0100

    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.
---
 gnu/build/file-systems.scm |   15 +++++++++++----
 gnu/system.scm             |    6 ++++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index d83a4f6..f8b8697 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -295,9 +295,12 @@ the following:
     ;; The realm of canonicalization.
     (if (eq? title 'any)
         (if (string? spec)
-            (if (string-prefix? "/" spec)
-                'device
-                'label)
+            ;; The "--root=SPEC" kernel command-line option always provides a
+            ;; string, but the string can represent a device, a UUID, or a
+            ;; label.  So check for all three.
+            (cond ((string-prefix? "/" spec) 'device)
+                  ((string->uuid spec) 'uuid)
+                  (else 'label))
             'uuid)
         title))
 
@@ -323,7 +326,11 @@ the following:
      ;; Resolve the label.
      (resolve find-partition-by-label spec identity))
     ((uuid)
-     (resolve find-partition-by-uuid spec uuid->string))
+     (resolve find-partition-by-uuid
+              (if (string? spec)
+                  (string->uuid spec)
+                  spec)
+              uuid->string))
     (else
      (error "unknown device title" title))))
 
diff --git a/gnu/system.scm b/gnu/system.scm
index acb7f15..6dfcc0f 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -673,12 +673,14 @@ listed in OS.  The C library expects to find it under
       ((system      (operating-system-derivation os))
        (root-fs ->  (operating-system-root-file-system 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
                            (label (kernel->grub-label kernel))
                            (linux kernel)
                            (linux-arguments
-                            (cons* (string-append "--root="
-                                                  (file-system-device root-fs))
+                            (cons* (string-append "--root=" root-device)
                                    #~(string-append "--system=" #$system)
                                    #~(string-append "--load=" #$system
                                                     "/boot")



reply via email to

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