From patchwork Wed Jun 30 20:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Geerinckx-Rice X-Patchwork-Id: 30849 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 05EDC27BC83; Wed, 30 Jun 2021 21:20:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED, URIBL_SBL,URIBL_SBL_A autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6763327BC78 for ; Wed, 30 Jun 2021 21:20:21 +0100 (BST) Received: from localhost ([::1]:45440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lygh2-0002Oa-6Q for patchwork@mira.cbaines.net; Wed, 30 Jun 2021 16:20:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyggl-0002Nv-5w for guix-patches@gnu.org; Wed, 30 Jun 2021 16:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyggk-0007wD-UN for guix-patches@gnu.org; Wed, 30 Jun 2021 16:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyggk-0004H8-QC for guix-patches@gnu.org; Wed, 30 Jun 2021 16:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49301] [PATCH 2/3] linux-boot: Honour fsck.mode & fsck.repair. Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Jun 2021 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49301 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49301@debbugs.gnu.org Received: via spool by 49301-submit@debbugs.gnu.org id=B49301.162508439116387 (code B ref 49301); Wed, 30 Jun 2021 20:20:02 +0000 Received: (at 49301) by debbugs.gnu.org; 30 Jun 2021 20:19:51 +0000 Received: from localhost ([127.0.0.1]:58890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyggZ-0004GF-3h for submit@debbugs.gnu.org; Wed, 30 Jun 2021 16:19:51 -0400 Received: from tobias.gr ([80.241.217.52]:49468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyggV-0004Fr-KV for 49301@debbugs.gnu.org; Wed, 30 Jun 2021 16:19:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=l4cHhdsuxKAxy O970IdDcpg8NDgrOi1s9k5sAuq4SAE=; h=references:in-reply-to:date: subject:to:from; d=tobias.gr; b=hBSx5x2UeeK0C4AOhaj9csUZdAfT67X40RCQq9 PG9qaAtYMZHOtDNRBWIK4HWydJUNo6Do2TVN4O6tOv2E/HqtB1OGc43MgpGN80H4puRLod q9IMtvdA4iy5kUno8v9mYFu3aEPOX9pslLiatD2FwU7efw14AD0176Tl04FOHoljRCgKR4 C0qRWQAXetVptFrnq9wcbVt444m1wyDXm/PvAKqZ956leOx9567ZN0MMGZ4jXSHqyS+u1C 4/dEGsSF5O89hb2sdOhPHo15xj1PhjqFTuMqivxE9NxdAImpZCYWnbstjE/phfCn+S/f2v kmAL2drY+RZi3fP4rM37ZqLg== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 661ca2db (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <49301@debbugs.gnu.org>; Wed, 30 Jun 2021 20:19:43 +0000 (UTC) Date: Wed, 30 Jun 2021 22:20:17 +0200 Message-Id: <20210630202018.19124-2-me@tobias.gr> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210630202018.19124-1-me@tobias.gr> References: <20210630202018.19124-1-me@tobias.gr> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches X-Patchwork-Original-From: Tobias Geerinckx-Rice via Guix-patches via From: Tobias Geerinckx-Rice X-getmail-retrieved-from-mailbox: Patches * 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." ;; 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)