@@ -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}.
@@ -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)