mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 06:06:53 -05:00
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.
This commit is contained in:
parent
42d41d86f3
commit
281d80d8e5
3 changed files with 36 additions and 40 deletions
|
@ -26534,9 +26534,10 @@ service activation programs and then spawns the GNU@tie{}Shepherd, the
|
||||||
initialization system.
|
initialization system.
|
||||||
|
|
||||||
@item --root=@var{root}
|
@item --root=@var{root}
|
||||||
Mount @var{root} as the root file system. @var{root} can be a
|
Mount @var{root} as the root file system. @var{root} can be a device
|
||||||
device name like @code{/dev/sda1}, a file system label, or a file system
|
name like @code{/dev/sda1}, a file system label, or a file system UUID.
|
||||||
UUID.
|
When unspecified, the device name from the root file system of the
|
||||||
|
operating system declaration is used.
|
||||||
|
|
||||||
@item --system=@var{system}
|
@item --system=@var{system}
|
||||||
Have @file{/run/booted-system} and @file{/run/current-system} point to
|
Have @file{/run/booted-system} and @file{/run/current-system} point to
|
||||||
|
|
|
@ -661,8 +661,10 @@ (define (resolve find-partition spec fmt)
|
||||||
|
|
||||||
(match spec
|
(match spec
|
||||||
((? string?)
|
((? string?)
|
||||||
;; Nothing to do, but wait until SPEC shows up.
|
(if (string-contains spec ":/")
|
||||||
(resolve identity spec identity))
|
spec ; do not resolve NFS devices
|
||||||
|
;; Nothing to do, but wait until SPEC shows up.
|
||||||
|
(resolve identity spec identity)))
|
||||||
((? file-system-label?)
|
((? file-system-label?)
|
||||||
;; Resolve the label.
|
;; Resolve the label.
|
||||||
(resolve find-partition-by-label
|
(resolve find-partition-by-label
|
||||||
|
|
|
@ -498,25 +498,13 @@ (define* (boot-system #:key
|
||||||
(define (root-mount-point? fs)
|
(define (root-mount-point? fs)
|
||||||
(string=? (file-system-mount-point fs) "/"))
|
(string=? (file-system-mount-point fs) "/"))
|
||||||
|
|
||||||
(define root-fs-type
|
(define (device-string->file-system-device device-string)
|
||||||
(or (any (lambda (fs)
|
;; The "--root=SPEC" kernel command-line option always provides a
|
||||||
(and (root-mount-point? fs)
|
;; string, but the string can represent a device, a UUID, or a
|
||||||
(file-system-type fs)))
|
;; label. So check for all three.
|
||||||
mounts)
|
(cond ((string-prefix? "/" device-string) device-string)
|
||||||
"ext4"))
|
((uuid device-string) => identity)
|
||||||
|
(else (file-system-label device-string))))
|
||||||
(define root-fs-flags
|
|
||||||
(mount-flags->bit-mask (or (any (lambda (fs)
|
|
||||||
(and (root-mount-point? fs)
|
|
||||||
(file-system-flags fs)))
|
|
||||||
mounts)
|
|
||||||
'())))
|
|
||||||
|
|
||||||
(define root-fs-options
|
|
||||||
(any (lambda (fs)
|
|
||||||
(and (root-mount-point? fs)
|
|
||||||
(file-system-options fs)))
|
|
||||||
mounts))
|
|
||||||
|
|
||||||
(display "Welcome, this is GNU's early boot Guile.\n")
|
(display "Welcome, this is GNU's early boot Guile.\n")
|
||||||
(display "Use '--repl' for an initrd REPL.\n\n")
|
(display "Use '--repl' for an initrd REPL.\n\n")
|
||||||
|
@ -526,7 +514,21 @@ (define root-fs-options
|
||||||
(mount-essential-file-systems)
|
(mount-essential-file-systems)
|
||||||
(let* ((args (linux-command-line))
|
(let* ((args (linux-command-line))
|
||||||
(to-load (find-long-option "--load" args))
|
(to-load (find-long-option "--load" args))
|
||||||
(root (find-long-option "--root" args)))
|
(root-fs (find root-mount-point? mounts))
|
||||||
|
(root-fs-type (or (and=> root-fs file-system-type)
|
||||||
|
"ext4"))
|
||||||
|
(root-fs-device (and=> root-fs file-system-device))
|
||||||
|
(root-fs-flags (mount-flags->bit-mask
|
||||||
|
(or (and=> root-fs file-system-flags)
|
||||||
|
'())))
|
||||||
|
(root-options (if root-fs
|
||||||
|
(file-system-options root-fs)
|
||||||
|
#f))
|
||||||
|
;; --root takes precedence over the 'device' field of the root
|
||||||
|
;; <file-system> record.
|
||||||
|
(root-device (or (and=> (find-long-option "--root" args)
|
||||||
|
device-string->file-system-device)
|
||||||
|
root-fs-device)))
|
||||||
|
|
||||||
(when (member "--repl" args)
|
(when (member "--repl" args)
|
||||||
(start-repl))
|
(start-repl))
|
||||||
|
@ -561,21 +563,12 @@ (define root-fs-options
|
||||||
|
|
||||||
(setenv "EXT2FS_NO_MTAB_OK" "1")
|
(setenv "EXT2FS_NO_MTAB_OK" "1")
|
||||||
|
|
||||||
(if root
|
(if root-device
|
||||||
;; The "--root=SPEC" kernel command-line option always provides a
|
(mount-root-file-system (canonicalize-device-spec root-device)
|
||||||
;; string, but the string can represent a device, a UUID, or a
|
root-fs-type
|
||||||
;; label. So check for all three.
|
#:volatile-root? volatile-root?
|
||||||
(let ((device-spec (cond ((string-prefix? "/" root) root)
|
#:flags root-fs-flags
|
||||||
((uuid root) => identity)
|
#:options root-options)
|
||||||
((string-contains root ":/") #f) ; nfs
|
|
||||||
(else (file-system-label root)))))
|
|
||||||
(mount-root-file-system (if device-spec
|
|
||||||
(canonicalize-device-spec device-spec)
|
|
||||||
root)
|
|
||||||
root-fs-type
|
|
||||||
#:volatile-root? volatile-root?
|
|
||||||
#:flags root-fs-flags
|
|
||||||
#:options root-fs-options))
|
|
||||||
(mount "none" "/root" "tmpfs"))
|
(mount "none" "/root" "tmpfs"))
|
||||||
|
|
||||||
;; Mount the specified file systems.
|
;; Mount the specified file systems.
|
||||||
|
|
Loading…
Reference in a new issue