All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] fs/cpio/init: remout / as read-only as a first step
Date: Tue,  4 Jul 2017 12:01:04 -0700	[thread overview]
Message-ID: <20170704190104.24703-1-andrew.smirnov@gmail.com> (raw)

When /init is present on root file system kernel does not take into
accout kernel arguments such as "ro" and does not remount root as
read-only. So prior to this commit the system would continue booting
with "rw" root filesystem until corresponding line in /etc/fstab to
remount it as "ro" was processed.

Change the code to immediately remount / as read-only and rely on
/etc/fstab processing to remount it as "rw" if that is what's selected
in Buildroot configuration.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---

Hi everyone,

Here's a little bit of a backstory for this patch:

I have a PowerPC, systemd based system that is set up to build and boot
from a compressed CPIO image. The system is build using stock
Buildroot with a number of patches from
https://git.buildroot.org/~ymorin/git/buildroot/log/?h=yem/systemd-skeleton
on top of it (to fix bug 7892).

Running against systemd 232 (not reproducable with 233), I would
occasionally see "systemd-remount-fs.service" fail to start because it
would try to re-mount '/' as read-only and fail due to '/' being
busy (I never figured out exactly what process was writing
there). That particular failure, being not very critical on my setup,
would leave my system in a state where everything worked as before,
but root filesystem would be accessible for writing.

Since all of the above run contrary to my expectaions (I expected
rootfs to be read-only to begin with) I went onto reading kernel
source to see if all of this was because I somehow misconfigured my
kernel boot paramters. As I mentioned in commit message, doing so
revealed that, when "/init" is present in the system, kernel would
mount root as R/W and pass control onto "/init" without trying to
honor "ro" bootflag. So, as far I can tell, in setup like this, it is
the responsiblity of "/init" script/executable to set things up
"correctly".

Needless to say that applying the change made my original problem --
"systemd-remount-fs.service" failing -- not reproducable.

I am not sure if this is a geniunly good fix or if I missed something
blatantly obvious and all of the above is my fault, so please let me
know what you think.

Thanks,
Andrey Smirnov

 fs/cpio/init | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/cpio/init b/fs/cpio/init
index a275482..349f98b 100755
--- a/fs/cpio/init
+++ b/fs/cpio/init
@@ -1,5 +1,6 @@
 #!/bin/sh
 # devtmpfs does not get automounted for initramfs
+/bin/mount -o remount,ro /dev/root
 /bin/mount -t devtmpfs devtmpfs /dev
 exec 0</dev/console
 exec 1>/dev/console
-- 
2.9.4

             reply	other threads:[~2017-07-04 19:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 19:01 Andrey Smirnov [this message]
2017-07-05 14:17 ` [Buildroot] [PATCH] fs/cpio/init: remout / as read-only as a first step Peter Korsgaard
2017-07-05 20:52   ` Andrey Smirnov
2017-07-05 22:18     ` Arnout Vandecappelle
2017-07-06  0:17       ` Andrey Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170704190104.24703-1-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.