3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

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.
This commit is contained in:
Tobias Geerinckx-Rice 2021-05-23 17:02:29 +02:00
parent 602994847b
commit a75a3d7132
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79
2 changed files with 63 additions and 28 deletions

View file

@ -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 When unspecified, the device name from the root file system of the
operating system declaration is used. 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} @item --system=@var{system}
Have @file{/run/booted-system} and @file{/run/current-system} point to Have @file{/run/booted-system} and @file{/run/current-system} point to
@var{system}. @var{system}.

View file

@ -541,21 +541,36 @@ upon error."
(mount-essential-file-systems) (mount-essential-file-systems)
(let* ((args (linux-command-line)) (let* ((args (linux-command-line))
(to-load (find-long-option "--load" args)) (to-load (find-long-option "--load" args))
(root-fs (find root-mount-point? mounts)) ;; If present, --root on the kernel command line takes precedence
(root-fs-type (or (and=> root-fs file-system-type) ;; over the device field of the root <file-system> record.
"ext4")) (root-device (and=> (find-long-option "--root" args)
(root-fs-device (and=> root-fs file-system-device)) device-string->file-system-device))
(root-fs-flags (mount-flags->bit-mask (root-fs (or (find root-mount-point? mounts)
(or (and=> root-fs file-system-flags) ;; Fall back to fictitious defaults.
'()))) (file-system (device (or root-device "/dev/root"))
(root-options (if root-fs (mount-point "/")
(file-system-options root-fs) (type "ext4"))))
#f)) (fsck.mode (find-long-option "fsck.mode" args)))
;; --root takes precedence over the 'device' field of the root
;; <file-system> record. (define (check? fs)
(root-device (or (and=> (find-long-option "--root" args) (match fsck.mode
device-string->file-system-device) ("skip" #f)
root-fs-device))) ("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) (when (member "--repl" args)
(start-repl)) (start-repl))
@ -611,23 +626,24 @@ upon error."
(if root-device (if root-device
(mount-root-file-system (canonicalize-device-spec root-device) (mount-root-file-system (canonicalize-device-spec root-device)
root-fs-type (file-system-type root-fs)
#:volatile-root? volatile-root? #:volatile-root? volatile-root?
#:flags root-fs-flags #:flags (mount-flags->bit-mask
#:options root-options (file-system-flags root-fs))
#:check? (if root-fs #:options (file-system-options root-fs)
(file-system-check? root-fs) #:check? (check? root-fs)
#t)
#:skip-check-if-clean? #:skip-check-if-clean?
(and=> root-fs (skip-check-if-clean? root-fs)
file-system-skip-check-if-clean?) #:repair (repair root-fs))
#:repair (if root-fs
(file-system-repair root-fs)
'preen))
(mount "none" "/root" "tmpfs")) (mount "none" "/root" "tmpfs"))
;; Mount the specified file systems. ;; Mount the specified non-root file systems.
(for-each mount-file-system (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)) (remove root-mount-point? mounts))
(setenv "EXT2FS_NO_MTAB_OK" #f) (setenv "EXT2FS_NO_MTAB_OK" #f)