All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: Vyacheslav Yurkov <uvv.mail@gmail.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] overlayfs-etc: take read-only-rootfs into account
Date: Sun, 11 Feb 2024 15:23:55 +0200	[thread overview]
Message-ID: <87cyt35dcy.fsf@tarshish> (raw)
In-Reply-To: <5066577e-7447-4f4f-8212-7729a3ada8ba@gmail.com>

Hi Slava,

On Thu, Feb 08 2024, Vyacheslav Yurkov wrote:
> On 08.02.2024 08:22, Baruch Siach wrote:
>> Don't remount rootfs read-write when read-only-rootfs feature is
>> enabled. Assume that all mount points are in place for the read-only
>> case.
>>
>> Cc: Vyacheslav Yurkov <uvv.mail@gmail.com>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>> ---
>>   meta/classes-recipe/overlayfs-etc.bbclass |  4 +++-
>>   meta/files/overlayfs-etc-preinit.sh.in    | 16 +++++++++-------
>>   2 files changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/meta/classes-recipe/overlayfs-etc.bbclass b/meta/classes-recipe/overlayfs-etc.bbclass
>> index 0c7834d01f43..e695ebdcf843 100644
>> --- a/meta/classes-recipe/overlayfs-etc.bbclass
>> +++ b/meta/classes-recipe/overlayfs-etc.bbclass
>> @@ -69,7 +69,9 @@ python create_overlayfs_etc_preinit() {
>>           'OVERLAYFS_ETC_FSTYPE': overlayEtcFsType,
>>           'OVERLAYFS_ETC_DEVICE': overlayEtcDevice,
>>           'SBIN_INIT_NAME': initBaseName + origInitNameSuffix if useOrigInit else initBaseName,
>> -        'OVERLAYFS_ETC_EXPOSE_LOWER': "true" if exposeLower else "false"
>> +        'OVERLAYFS_ETC_EXPOSE_LOWER': "true" if exposeLower else "false",
>> +        'READ_ONLY_ROOTFS': bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
>> +                                              "true", "false", d)
>>       }
>>         if useOrigInit:
>> diff --git a/meta/files/overlayfs-etc-preinit.sh.in b/meta/files/overlayfs-etc-preinit.sh.in
>> index 8db076f4ba65..79cecf8ac97d 100644
>> --- a/meta/files/overlayfs-etc-preinit.sh.in
>> +++ b/meta/files/overlayfs-etc-preinit.sh.in
>> @@ -3,12 +3,15 @@
>>   echo "PREINIT: Start"
>>     PATH=/sbin:/bin:/usr/sbin:/usr/bin
>> -mount -o remount,rw /
>> -
>> -mkdir -p /proc
>> -mkdir -p /sys
>> -mkdir -p /run
>> -mkdir -p /var/run
>> +if ! {READ_ONLY_ROOTFS}; then
>> +    mount -o remount,rw /
>> +
>> +    mkdir -p /proc
>> +    mkdir -p /sys
>> +    mkdir -p /run
>> +    mkdir -p /var/run
>> +    mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
>> +fi
>
> I don't think this would be a correct approach. You probably should only
> remount to ro after all mount points are created.

As I understand, the point of read-only-rootfs feature is to keep rootfs
intact. Filesystems like squashfs or erofs don't support rw mount at
all. How can we support this use case?

> With this patch overlayfs.OverlayFSEtcRunTimeTests.test_sbin_init_preinit
> fails:
>
> 2024-02-08 21:12:40,616 - oe-selftest - INFO - Traceback (most recent call
> last):
>   File
> "/home/uvv/projects/upstream/poky/meta/lib/oeqa/core/decorator/__init__.py",
> line 35, in wrapped_f
>     return func(*args, **kwargs)
>   File
> "/home/uvv/projects/upstream/poky/meta/lib/oeqa/selftest/cases/overlayfs.py",
> line 370, in test_sbin_init_preinit
>     self.run_sbin_init(False)
>   File
> "/home/uvv/projects/upstream/poky/meta/lib/oeqa/selftest/cases/overlayfs.py",
> line 399, in run_sbin_init
>     self.assertTrue("/data" in output, msg=output)
> AssertionError: False is not true : /dev/sda2 on / type ext4 (ro,relatime)

Where is this /dev/sda2 coming from? I have also seen it in my
/etc/fstab once I enabled the overlayfs-etc feature. I see no mention of
sda2 in meta/lib/oeqa/selftest/cases/overlayfs.py.

> The test is not really explicit, but it looks like overlay is not mounted. We
> could also add a generic test to search for "PREINIT" done/failed.

How can I run this test?

Thanks,
baruch

>
>>   mount -t proc proc /proc
>>   mount -t sysfs sysfs /sys
>> @@ -20,7 +23,6 @@ UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper
>>   WORK_DIR=$BASE_OVERLAY_ETC_DIR/work
>>   LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower
>>   -mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
>>   if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
>>       -o {OVERLAYFS_ETC_MOUNT_OPTIONS} \
>>       {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT}
>
> Thanks,
> Slava


-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


  reply	other threads:[~2024-02-11 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08  7:22 [PATCH] overlayfs-etc: take read-only-rootfs into account Baruch Siach
2024-02-08 20:21 ` Vyacheslav Yurkov
2024-02-11 13:23   ` Baruch Siach [this message]
2024-02-11 18:22     ` Vyacheslav Yurkov
2024-02-12 14:21       ` Baruch Siach
2024-02-12 18:38         ` Vyacheslav Yurkov
2024-02-12 18:40           ` Baruch Siach

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=87cyt35dcy.fsf@tarshish \
    --to=baruch@tkos.co.il \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=uvv.mail@gmail.com \
    /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.