summaryrefslogtreecommitdiff
path: root/gnu/build/linux-boot.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2020-02-11 14:00:06 -0500
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2020-05-20 08:30:34 -0400
commit281d80d8e547fe663aaacb3226119166dd3100f9 (patch)
treeb666edb5528f263fa857ef231a4824f2ec1ffe7e /gnu/build/linux-boot.scm
parent42d41d86f38958ebcff370b0e56da5c69165943c (diff)
linux-boot: Refactor boot-system.
The --root option can now be omitted, and inferred from the root file system declaration instead. * gnu/build/file-systems.scm (canonicalize-device-spec): Extend to support NFS directly, and... * gnu/build/linux-boot.scm (boot-system): ...remove NFS special casing from here. Remove nested definitions for root-fs-type, root-fs-flags and root-fs-options, and bind those inside the let* instead. Make "--root" take precedence over the device field string representation of the root file system. * doc/guix.texi (Initial RAM Disk): Document that "--root" can be left unspecified.
Diffstat (limited to 'gnu/build/linux-boot.scm')
-rw-r--r--gnu/build/linux-boot.scm63
1 files changed, 28 insertions, 35 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index c6f9df5f297..f08bb115146 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -498,25 +498,13 @@ upon error."
498 (define (root-mount-point? fs) 498 (define (root-mount-point? fs)
499 (string=? (file-system-mount-point fs) "/")) 499 (string=? (file-system-mount-point fs) "/"))
500 500
501 (define root-fs-type 501 (define (device-string->file-system-device device-string)
502 (or (any (lambda (fs) 502 ;; The "--root=SPEC" kernel command-line option always provides a
503 (and (root-mount-point? fs) 503 ;; string, but the string can represent a device, a UUID, or a
504 (file-system-type fs))) 504 ;; label. So check for all three.
505 mounts) 505 (cond ((string-prefix? "/" device-string) device-string)
506 "ext4")) 506 ((uuid device-string) => identity)
507 507 (else (file-system-label device-string))))
508 (define root-fs-flags
509 (mount-flags->bit-mask (or (any (lambda (fs)
510 (and (root-mount-point? fs)
511 (file-system-flags fs)))
512 mounts)
513 '())))
514
515 (define root-fs-options
516 (any (lambda (fs)
517 (and (root-mount-point? fs)
518 (file-system-options fs)))
519 mounts))
520 508
521 (display "Welcome, this is GNU's early boot Guile.\n") 509 (display "Welcome, this is GNU's early boot Guile.\n")
522 (display "Use '--repl' for an initrd REPL.\n\n") 510 (display "Use '--repl' for an initrd REPL.\n\n")
@@ -526,7 +514,21 @@ upon error."
526 (mount-essential-file-systems) 514 (mount-essential-file-systems)
527 (let* ((args (linux-command-line)) 515 (let* ((args (linux-command-line))
528 (to-load (find-long-option "--load" args)) 516 (to-load (find-long-option "--load" args))
529 (root (find-long-option "--root" args))) 517 (root-fs (find root-mount-point? mounts))
518 (root-fs-type (or (and=> root-fs file-system-type)
519 "ext4"))
520 (root-fs-device (and=> root-fs file-system-device))
521 (root-fs-flags (mount-flags->bit-mask
522 (or (and=> root-fs file-system-flags)
523 '())))
524 (root-options (if root-fs
525 (file-system-options root-fs)
526 #f))
527 ;; --root takes precedence over the 'device' field of the root
528 ;; <file-system> record.
529 (root-device (or (and=> (find-long-option "--root" args)
530 device-string->file-system-device)
531 root-fs-device)))
530 532
531 (when (member "--repl" args) 533 (when (member "--repl" args)
532 (start-repl)) 534 (start-repl))
@@ -561,21 +563,12 @@ upon error."
561 563
562 (setenv "EXT2FS_NO_MTAB_OK" "1") 564 (setenv "EXT2FS_NO_MTAB_OK" "1")
563 565
564 (if root 566 (if root-device
565 ;; The "--root=SPEC" kernel command-line option always provides a 567 (mount-root-file-system (canonicalize-device-spec root-device)
566 ;; string, but the string can represent a device, a UUID, or a 568 root-fs-type
567 ;; label. So check for all three. 569 #:volatile-root? volatile-root?
568 (let ((device-spec (cond ((string-prefix? "/" root) root) 570 #:flags root-fs-flags
569 ((uuid root) => identity) 571 #:options root-options)
570 ((string-contains root ":/") #f) ; nfs
571 (else (file-system-label root)))))
572 (mount-root-file-system (if device-spec
573 (canonicalize-device-spec device-spec)
574 root)
575 root-fs-type
576 #:volatile-root? volatile-root?
577 #:flags root-fs-flags
578 #:options root-fs-options))
579 (mount "none" "/root" "tmpfs")) 572 (mount "none" "/root" "tmpfs"))
580 573
581 ;; Mount the specified file systems. 574 ;; Mount the specified file systems.