all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tobias Geerinckx-Rice via Guix-patches via <guix-patches@gnu.org>
To: 49301@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	[thread overview]
Message-ID: <20210630202018.19124-2-me@tobias.gr> (raw)
In-Reply-To: <20210630202018.19124-1-me@tobias.gr>

* 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





  reply	other threads:[~2021-06-30 20:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-30 20:15 [bug#49301] [PATCH 0/3] Give users control over file system checks Tobias Geerinckx-Rice via Guix-patches via
2021-06-30 20:20 ` [bug#49301] [PATCH 1/3] file-systems: Support forced checks & repairs Tobias Geerinckx-Rice via Guix-patches via
2021-06-30 20:20   ` Tobias Geerinckx-Rice via Guix-patches via [this message]
2021-06-30 20:20   ` [bug#49301] [PATCH 3/3] gnu: Don't abuse check-btrfs-file-system to scan Tobias Geerinckx-Rice via Guix-patches via
2021-07-07 15:09   ` [bug#49301] [PATCH 0/3] Give users control over file system checks Mathieu Othacehe
2021-08-31 14:05     ` Mathieu Othacehe
2021-09-23 16:40 ` bug#49301: " Tobias Geerinckx-Rice via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210630202018.19124-2-me@tobias.gr \
    --to=guix-patches@gnu.org \
    --cc=49301@debbugs.gnu.org \
    --cc=me@tobias.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.