From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 09 May 2024 13:40:32 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1s528V-0059T5-2h for lore@lore.pengutronix.de; Thu, 09 May 2024 13:40:32 +0200 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1s528V-0002cN-6E; Thu, 09 May 2024 13:40:31 +0200 Received: from smtp74.iad3b.emailsrvr.com ([146.20.161.74]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s528C-0002bO-PL for ptxdist@pengutronix.de; Thu, 09 May 2024 13:40:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1715254810; bh=b1gsUD0O4A8wdO5Eb+/ew/1tm6nK5c/qPTgwCiqscD0=; h=Date:Subject:To:From:From; b=QmutDa3j37H+IZRjHW2Ire+cDVVlrwFAszqNbjD/OfM8D5JqpwNHiFfzCZV5O4psv gbDbMOEEl1DF6p41l5seBnBRzPuKsZJs+xOOQPQghXK+IrBOuZlNE3Wt1nhul9ZIg+ sqiFfs9btVGSlt7DDAH5KQxe2PEh0a1z3OMTPQVA= X-Auth-ID: abbotti@mev.co.uk Received: by smtp18.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 414E4E01F9 for ; Thu, 9 May 2024 07:40:10 -0400 (EDT) Message-ID: <6c35a8a3-d454-406e-ad40-cd37139df009@mev.co.uk> Date: Thu, 9 May 2024 12:40:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB To: ptxdist@pengutronix.de References: From: Ian Abbott Organization: MEV Ltd. In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Classification-ID: a76a3daf-47da-4662-a510-4f93fe2e6ab8-1-1 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-3.6 required=4.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] Race condition between rc-once.service and systemd-remount-fs.service X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false On 09/05/2024 10:34, Michael Olbrich wrote: > On Fri, May 03, 2024 at 07:33:32PM +0100, Ian Abbott wrote: >> If the root file system is initially mounted read-only, there is a possible >> race between rc-once.service and the systemd-remount-fs.service. If >> rc-once.service sees the root filesystem is mounted read-only, then it will >> temporarily remount it read-write and later mount it read-only again. >> Meanwhile, systemd-remount-fs.service will also remount the root file system >> as specified by /etc/fstab which could be read-write. Depending on the >> ordering, it is possible for the root file-system to end up mounted >> read-only when it should have ended up mounted read-write. >> >> As long as the two services do not run simultaneously, the root file system >> should end up mounted in the correct state. However, I do not know what the >> intended order is supposed to be. Perhaps it is intentionally >> system-dependent? > > It's not intentional. I just never noticed because I always keep the rootfs > read-only by default. I think rc-once.service should have > 'After=systemd-remount-fs.service'. That should fix the problem, right? That's what I have done locally and it seems to work. One slightly related tip for people using systemd is to avoid using busybox's 'mount' command when systemd is being used. Use the mount command from util-linux instead). This is because busybox's mount command does not read the /etc/fstab file for remount operations, it only reads the mtab file. For example, if the root file system is currently mounted read-only, but is not marked as read-only in /etc/fstab, the systemd-remount-fs.service will run `mount / -o remount`, and busybox's mount will remount it read-only again, whereas util-linux's mount will remount it read-write as intended. -- -=( Ian Abbott || MEV Ltd. is a company )=- -=( registered in England & Wales. Regd. number: 02862268. )=- -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=- -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-