Package: guix-patches;
Reported by: Tobias Geerinckx-Rice <me <at> tobias.gr>
Date: Wed, 30 Jun 2021 20:17:01 UTC
Severity: normal
Tags: patch
Done: Tobias Geerinckx-Rice <me <at> tobias.gr>
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: Tobias Geerinckx-Rice <me <at> tobias.gr> To: 49301 <at> debbugs.gnu.org Subject: [bug#49301] [PATCH 2/3] linux-boot: Honour fsck.mode & fsck.repair. Date: Wed, 30 Jun 2021 22:20:17 +0200
* 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. --- doc/guix.texi | 19 ++++++++++++++++++ gnu/build/linux-boot.scm | 43 +++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9fb5709f4f..0d17830a66 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32703,6 +32703,25 @@ name like @code{/dev/sda1}, a file system label, or a file system UUID. When unspecified, the device name from the root file system of the operating system declaration is used. +@item fsck.mode=@var{mode} +Whether to check the @var{root} file system for errors before mounting +it. @var{mode} is one of @code{skip} (never check), @code{force} (always +check), or @code{auto} to respect the root file-system object's 'check?' +setting (@pxref{File Systems}) and run a full scan only if the file system +was not cleanly shut down. + +@code{auto} is the default if this option is not present or if @var{mode} +is not one of the above. + +@item fsck.repair=@var{level} +The level of repairs to perform automatically if errors are found in the +@var{root} file system. @var{level} is one of @code{no} (do not write to +@var{root} at all if possible), @code{yes} (repair as much as possible), +or @code{preen} to repair problems considered safe to repair automatically. + +@code{preen} is the default if this option is not present or if @var{level} +is not one of the above. + @item --system=@var{system} Have @file{/run/booted-system} and @file{/run/current-system} point to @var{system}. diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 325e26c29a..c54b3b9b5a 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -561,7 +561,31 @@ upon error." ;; <file-system> record. (root-device (or (and=> (find-long-option "--root" args) device-string->file-system-device) - root-fs-device))) + root-fs-device)) + (fsck.mode (find-long-option "fsck.mode" args))) + + (define (check? fs) + (match fsck.mode + ("skip" #f) + ("force" #t) + ;; Handle #f because ROOT may be #f. + (_ (if fs (file-system-check? fs) #t)))) ; default mode is "auto" + + (define (skip-check-if-clean? fs) + (match fsck.mode + ("force" #f) + ;; Handle #f FS because ROOT may be #f. + (_ (and=> fs file-system-skip-check-if-clean?)))) + + (define (repair fs) + (let ((arg (find-long-option "fsck.repair" args))) + (if arg + (match arg + ("no" #f) + ("yes" #t) + (_ 'preen)) ; default ARG is "preen" + ;; Handle #f because ROOT may be #f. + (if fs (file-system-repair fs) 'preen)))) (when (member "--repl" args) (start-repl)) @@ -621,24 +645,19 @@ upon error." #:volatile-root? volatile-root? #:flags root-fs-flags #:options root-options - #:check? (if root-fs - (file-system-check? root-fs) - #t) + #:check? (check? root-fs) #:skip-check-if-clean? - (and=> root-fs - file-system-skip-check-if-clean?) - #:repair (if root-fs - (file-system-repair root-fs) - 'preen)) + (skip-check-if-clean? root-fs) + #:repair (repair root-fs)) (mount "none" "/root" "tmpfs")) ;; Mount the specified file systems. (for-each (lambda (fs) (mount-file-system fs - #:check? (file-system-check? fs) + #:check? (check? fs) #:skip-check-if-clean? - (file-system-skip-check-if-clean? fs) - #:repair (file-system-repair fs))) + (skip-check-if-clean? fs) + #:repair (repair fs))) (remove root-mount-point? mounts)) (setenv "EXT2FS_NO_MTAB_OK" #f) -- 2.32.0
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.