[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/17: linux-boot: Honour fsck.mode & fsck.repair.
From: |
guix-commits |
Subject: |
03/17: linux-boot: Honour fsck.mode & fsck.repair. |
Date: |
Thu, 23 Sep 2021 12:20:53 -0400 (EDT) |
nckx pushed a commit to branch master
in repository guix.
commit a75a3d71329d3ca07a2ef18b81fc7b463f703ed7
Author: Tobias Geerinckx-Rice <me@tobias.gr>
AuthorDate: Sun May 23 17:02:29 2021 +0200
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.
---
doc/guix.texi | 19 +++++++++++++
gnu/build/linux-boot.scm | 72 +++++++++++++++++++++++++++++-------------------
2 files changed, 63 insertions(+), 28 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index a62578b..dc9b039 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33285,6 +33285,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 ab05d1b..8f0f3eb 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -541,21 +541,36 @@ upon error."
(mount-essential-file-systems)
(let* ((args (linux-command-line))
(to-load (find-long-option "--load" 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)))
+ ;; If present, ‘--root’ on the kernel command line takes
precedence
+ ;; over the ‘device’ field of the root <file-system> record.
+ (root-device (and=> (find-long-option "--root" args)
+ device-string->file-system-device))
+ (root-fs (or (find root-mount-point? mounts)
+ ;; Fall back to fictitious defaults.
+ (file-system (device (or root-device "/dev/root"))
+ (mount-point "/")
+ (type "ext4"))))
+ (fsck.mode (find-long-option "fsck.mode" args)))
+
+ (define (check? fs)
+ (match fsck.mode
+ ("skip" #f)
+ ("force" #t)
+ (_ (file-system-check? fs)))) ; assume "auto"
+
+ (define (skip-check-if-clean? fs)
+ (match fsck.mode
+ ("force" #f)
+ (_ (file-system-skip-check-if-clean? fs))))
+
+ (define (repair fs)
+ (let ((arg (find-long-option "fsck.repair" args)))
+ (if arg
+ (match arg
+ ("no" #f)
+ ("yes" #t)
+ (_ 'preen))
+ (file-system-repair fs))))
(when (member "--repl" args)
(start-repl))
@@ -611,23 +626,24 @@ upon error."
(if root-device
(mount-root-file-system (canonicalize-device-spec root-device)
- root-fs-type
+ (file-system-type root-fs)
#:volatile-root? volatile-root?
- #:flags root-fs-flags
- #:options root-options
- #:check? (if root-fs
- (file-system-check? root-fs)
- #t)
+ #:flags (mount-flags->bit-mask
+ (file-system-flags root-fs))
+ #:options (file-system-options root-fs)
+ #: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 mount-file-system
+ ;; Mount the specified non-root file systems.
+ (for-each (lambda (fs)
+ (mount-file-system fs
+ #:check? (check? fs)
+ #:skip-check-if-clean?
+ (skip-check-if-clean? fs)
+ #:repair (repair fs)))
(remove root-mount-point? mounts))
(setenv "EXT2FS_NO_MTAB_OK" #f)
- branch master updated (e1401fb -> 0b298cb), guix-commits, 2021/09/23
- 09/17: gnu: Add xfsprogs-static., guix-commits, 2021/09/23
- 01/17: gnu: rsync: Enable zstd & lz4 compression., guix-commits, 2021/09/23
- 05/17: syscalls: Deduplicate device number conversion., guix-commits, 2021/09/23
- 04/17: gnu: Don't abuse check-btrfs-file-system to scan., guix-commits, 2021/09/23
- 03/17: linux-boot: Honour fsck.mode & fsck.repair.,
guix-commits <=
- 11/17: uuid: Support XFS., guix-commits, 2021/09/23
- 14/17: file-systems: Add support for XFS., guix-commits, 2021/09/23
- 17/17: tests: install: Test an XFS root file system., guix-commits, 2021/09/23
- 13/17: file-systems: Add file system to *-SUPERBLOCK-VOLUME-NAME docstrings., guix-commits, 2021/09/23
- 07/17: gnu: libinih: Build & install static libraries., guix-commits, 2021/09/23
- 02/17: file-systems: Support forced checks & repairs., guix-commits, 2021/09/23
- 08/17: gnu: xfsprogs: Build verbosely., guix-commits, 2021/09/23
- 06/17: linux-initrd: Include only the single ‘bcachefs’ binary., guix-commits, 2021/09/23
- 12/17: linux-initrd: Support XFS., guix-commits, 2021/09/23
- 10/17: gnu: Add xfs_repair-static., guix-commits, 2021/09/23