summaryrefslogtreecommitdiff
path: root/gnu/build/linux-boot.scm
diff options
context:
space:
mode:
authorTobias Geerinckx-Rice <me@tobias.gr>2021-05-23 17:02:29 +0200
committerTobias Geerinckx-Rice <me@tobias.gr>2021-09-23 18:17:16 +0200
commita75a3d71329d3ca07a2ef18b81fc7b463f703ed7 (patch)
treeb42f6ef705b935359f5768b10f45b5790310e243 /gnu/build/linux-boot.scm
parent602994847b748937b6fa39a7b819429857cdd8d3 (diff)
linux-boot: Honour fsck.mode & fsck.repair.
* gnu/build/linux-boot.scm (boot-system): Honour ‘fsck.mode=’ and ‘fsck.repair=’ kernel command line options. * doc/guix.texi (Initial RAM Disk): Document both.
Diffstat (limited to 'gnu/build/linux-boot.scm')
-rw-r--r--gnu/build/linux-boot.scm72
1 files changed, 44 insertions, 28 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index ab05d1ba5e0..8f0f3eb2fcc 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -541,21 +541,36 @@ upon error."
541 (mount-essential-file-systems) 541 (mount-essential-file-systems)
542 (let* ((args (linux-command-line)) 542 (let* ((args (linux-command-line))
543 (to-load (find-long-option "--load" args)) 543 (to-load (find-long-option "--load" args))
544 (root-fs (find root-mount-point? mounts)) 544 ;; If present, ‘--root’ on the kernel command line takes precedence
545 (root-fs-type (or (and=> root-fs file-system-type) 545 ;; over the ‘device’ field of the root <file-system> record.
546 "ext4")) 546 (root-device (and=> (find-long-option "--root" args)
547 (root-fs-device (and=> root-fs file-system-device)) 547 device-string->file-system-device))
548 (root-fs-flags (mount-flags->bit-mask 548 (root-fs (or (find root-mount-point? mounts)
549 (or (and=> root-fs file-system-flags) 549 ;; Fall back to fictitious defaults.
550 '()))) 550 (file-system (device (or root-device "/dev/root"))
551 (root-options (if root-fs 551 (mount-point "/")
552 (file-system-options root-fs) 552 (type "ext4"))))
553 #f)) 553 (fsck.mode (find-long-option "fsck.mode" args)))
554 ;; --root takes precedence over the 'device' field of the root 554
555 ;; <file-system> record. 555 (define (check? fs)
556 (root-device (or (and=> (find-long-option "--root" args) 556 (match fsck.mode
557 device-string->file-system-device) 557 ("skip" #f)
558 root-fs-device))) 558 ("force" #t)
559 (_ (file-system-check? fs)))) ; assume "auto"
560
561 (define (skip-check-if-clean? fs)
562 (match fsck.mode
563 ("force" #f)
564 (_ (file-system-skip-check-if-clean? fs))))
565
566 (define (repair fs)
567 (let ((arg (find-long-option "fsck.repair" args)))
568 (if arg
569 (match arg
570 ("no" #f)
571 ("yes" #t)
572 (_ 'preen))
573 (file-system-repair fs))))
559 574
560 (when (member "--repl" args) 575 (when (member "--repl" args)
561 (start-repl)) 576 (start-repl))
@@ -611,23 +626,24 @@ upon error."
611 626
612 (if root-device 627 (if root-device
613 (mount-root-file-system (canonicalize-device-spec root-device) 628 (mount-root-file-system (canonicalize-device-spec root-device)
614 root-fs-type 629 (file-system-type root-fs)
615 #:volatile-root? volatile-root? 630 #:volatile-root? volatile-root?
616 #:flags root-fs-flags 631 #:flags (mount-flags->bit-mask
617 #:options root-options 632 (file-system-flags root-fs))
618 #:check? (if root-fs 633 #:options (file-system-options root-fs)
619 (file-system-check? root-fs) 634 #:check? (check? root-fs)
620 #t)
621 #:skip-check-if-clean? 635 #:skip-check-if-clean?
622 (and=> root-fs 636 (skip-check-if-clean? root-fs)
623 file-system-skip-check-if-clean?) 637 #:repair (repair root-fs))
624 #:repair (if root-fs
625 (file-system-repair root-fs)
626 'preen))
627 (mount "none" "/root" "tmpfs")) 638 (mount "none" "/root" "tmpfs"))
628 639
629 ;; Mount the specified file systems. 640 ;; Mount the specified non-root file systems.
630 (for-each mount-file-system 641 (for-each (lambda (fs)
642 (mount-file-system fs
643 #:check? (check? fs)
644 #:skip-check-if-clean?
645 (skip-check-if-clean? fs)
646 #:repair (repair fs)))
631 (remove root-mount-point? mounts)) 647 (remove root-mount-point? mounts))
632 648
633 (setenv "EXT2FS_NO_MTAB_OK" #f) 649 (setenv "EXT2FS_NO_MTAB_OK" #f)