diff mbox series

[PATCHv2] wic-imager-direct.py: use fstab update also for root device

Message ID 20220930041807.2509199-1-f_l_k@t-online.de
State New
Headers show
Series [PATCHv2] wic-imager-direct.py: use fstab update also for root device | expand

Commit Message

Markus Volk Sept. 30, 2022, 4:18 a.m. UTC
wic imager is able to add entries for the partitions to fstab. This patch also
creates an entry for the root device, which was previously ignored. The root
device entry can now optionally be uuid or label based.

The stock fstab file provided by base-files.bb already contains an entry for the
root device. The result looks something like this:

/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0

UUID=055A-69B5 /boot vfat defaults 0 0
UUID=0eb2df23-3638-4bbf-b045-9a425cb45954 / ext4 defaults 0 0

To avoid duplicate root device entries in fstab for wic images, the "/dev/root"
line is removed during the update.

Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 scripts/lib/wic/plugins/imager/direct.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Markus Volk Sept. 30, 2022, 4:19 a.m. UTC | #1
i had a mail delivery error for this, so i resent

Am Fr, 30. Sep 2022 um 06:18:07 +0200 schrieb Markus Volk 
<f_l_k@t-online.de>:
> wic imager is able to add entries for the partitions to fstab. This 
> patch also
> creates an entry for the root device, which was previously ignored. 
> The root
> device entry can now optionally be uuid or label based.
> 
> The stock fstab file provided by base-files.bb already contains an 
> entry for the
> root device. The result looks something like this:
> 
> /dev/root / auto defaults 1 1
> proc /proc proc defaults 0 0
> devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
> tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
> tmpfs /var/volatile tmpfs defaults 0 0
> 
> UUID=055A-69B5 /boot vfat defaults 0 0
> UUID=0eb2df23-3638-4bbf-b045-9a425cb45954 / ext4 defaults 0 0
> 
> To avoid duplicate root device entries in fstab for wic images, the 
> "/dev/root"
> line is removed during the update.
> 
> Signed-off-by: Markus Volk <f_l_k@t-online.de 
> <mailto:f_l_k@t-online.de>>
> ---
>  scripts/lib/wic/plugins/imager/direct.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/wic/plugins/imager/direct.py 
> b/scripts/lib/wic/plugins/imager/direct.py
> index da483daed5..fd86a094d9 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -117,7 +117,7 @@ class DirectPlugin(ImagerPlugin):
>          updated = False
>          for part in self.parts:
>              if not part.realnum or not part.mountpoint \
> -               or part.mountpoint == "/" or not 
> part.mountpoint.startswith('/'):
> +               or not part.mountpoint.startswith('/'):
>                  continue
> 
>              if part.use_uuid:
> @@ -145,6 +145,11 @@ class DirectPlugin(ImagerPlugin):
>              fstab_lines.append(line)
>              updated = True
> 
> +        for line in fstab_lines:
> +            if '/dev/root' in line:
> +                fstab_lines.remove(line)
> +                updated = True
> +
>          if updated:
>              self.updated_fstab_path = os.path.join(self.workdir, 
> "fstab")
>              with open(self.updated_fstab_path, "w") as f:
> --
> 2.34.1
>
Alexandre Belloni Sept. 30, 2022, 11:11 p.m. UTC | #2
Hello Markus,

This causes the following failure:
https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/4140/steps/14/logs/stdio

On 30/09/2022 06:18:07+0200, Markus Volk wrote:
> wic imager is able to add entries for the partitions to fstab. This patch also
> creates an entry for the root device, which was previously ignored. The root
> device entry can now optionally be uuid or label based.
> 
> The stock fstab file provided by base-files.bb already contains an entry for the
> root device. The result looks something like this:
> 
> /dev/root / auto defaults 1 1
> proc /proc proc defaults 0 0
> devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
> tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
> tmpfs /var/volatile tmpfs defaults 0 0
> 
> UUID=055A-69B5 /boot vfat defaults 0 0
> UUID=0eb2df23-3638-4bbf-b045-9a425cb45954 / ext4 defaults 0 0
> 
> To avoid duplicate root device entries in fstab for wic images, the "/dev/root"
> line is removed during the update.
> 
> Signed-off-by: Markus Volk <f_l_k@t-online.de>
> ---
>  scripts/lib/wic/plugins/imager/direct.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
> index da483daed5..fd86a094d9 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -117,7 +117,7 @@ class DirectPlugin(ImagerPlugin):
>          updated = False
>          for part in self.parts:
>              if not part.realnum or not part.mountpoint \
> -               or part.mountpoint == "/" or not part.mountpoint.startswith('/'):
> +               or not part.mountpoint.startswith('/'):
>                  continue
>  
>              if part.use_uuid:
> @@ -145,6 +145,11 @@ class DirectPlugin(ImagerPlugin):
>              fstab_lines.append(line)
>              updated = True
>  
> +        for line in fstab_lines:
> +            if '/dev/root' in line:
> +                fstab_lines.remove(line)
> +                updated = True
> +
>          if updated:
>              self.updated_fstab_path = os.path.join(self.workdir, "fstab")
>              with open(self.updated_fstab_path, "w") as f:
> -- 
> 2.34.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#171205): https://lists.openembedded.org/g/openembedded-core/message/171205
> Mute This Topic: https://lists.openembedded.org/mt/94010270/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Markus Volk Oct. 8, 2022, 12:53 p.m. UTC | #3
Am Sa, 1. Okt 2022 um 01:11:46 +0200 schrieb Alexandre Belloni via 
lists.openembedded.org 
<alexandre.belloni=bootlin.com@lists.openembedded.org>:
> This causes the following failure:
> <https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/4140/steps/14/logs/stdio>

Hi Alexandre,

I've looked at the problem and can reproduce the errors when I run 
'oe-selftest -v -r overlay-fs', but unfortunately I can't really see 
what exactly the problem is. qemu just ends unexpectedly and doesn't 
give much useful information in its output. At least I am not able to 
find it.
Alexandre Belloni Oct. 8, 2022, 1:03 p.m. UTC | #4
On 08/10/2022 14:53:48+0200, Markus Volk wrote:
> Am Sa, 1. Okt 2022 um 01:11:46 +0200 schrieb Alexandre Belloni via
> lists.openembedded.org
> <alexandre.belloni=bootlin.com@lists.openembedded.org>:
> > This causes the following failure:
> > <https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/4140/steps/14/logs/stdio>
> 
> Hi Alexandre,
> 
> I've looked at the problem and can reproduce the errors when I run
> 'oe-selftest -v -r overlay-fs', but unfortunately I can't really see what
> exactly the problem is. qemu just ends unexpectedly and doesn't give much
> useful information in its output. At least I am not able to find it.
> 

The issue is probably that one:
AssertionError: None is not true : diff: can't stat '/data/overlay-etc/lower/lower-layer-test.txt': No such file or directory

is /data in /etc/fstab?
Markus Volk Feb. 7, 2023, 12:44 p.m. UTC | #5
I recently stumbled across this patch again and thought about possible 
pitfalls once more. I can't check the overlayfs selftest unfortunately. 
When I start it, it takes a long while and then 7 tests are successful 
and 6 are missing with 'qemu ended unexpectedly'. Regardless of whether 
I apply this patch. Probably my host system is missing something more 
basic for the qemu tests. I am not very knowledgeable about this.

But what I could imagine if the test still fails is that it might help 
to remove '--use-uuid' from meta-selftest/wic/overlayfs_etc.wks.in.

I will send another attempt for this and try to contact everyone who has 
dealt with the problem so far.

Am 08.10.22 um 15:03 schrieb Alexandre Belloni:
> On 08/10/2022 14:53:48+0200, Markus Volk wrote:
>> Am Sa, 1. Okt 2022 um 01:11:46 +0200 schrieb Alexandre Belloni via
>> lists.openembedded.org
>> <alexandre.belloni=bootlin.com@lists.openembedded.org>:
>>> This causes the following failure:
>>> <https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/4140/steps/14/logs/stdio>
>> Hi Alexandre,
>>
>> I've looked at the problem and can reproduce the errors when I run
>> 'oe-selftest -v -r overlay-fs', but unfortunately I can't really see what
>> exactly the problem is. qemu just ends unexpectedly and doesn't give much
>> useful information in its output. At least I am not able to find it.
>>
> The issue is probably that one:
> AssertionError: None is not true : diff: can't stat '/data/overlay-etc/lower/lower-layer-test.txt': No such file or directory
>
> is /data in /etc/fstab?
>
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index da483daed5..fd86a094d9 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -117,7 +117,7 @@  class DirectPlugin(ImagerPlugin):
         updated = False
         for part in self.parts:
             if not part.realnum or not part.mountpoint \
-               or part.mountpoint == "/" or not part.mountpoint.startswith('/'):
+               or not part.mountpoint.startswith('/'):
                 continue
 
             if part.use_uuid:
@@ -145,6 +145,11 @@  class DirectPlugin(ImagerPlugin):
             fstab_lines.append(line)
             updated = True
 
+        for line in fstab_lines:
+            if '/dev/root' in line:
+                fstab_lines.remove(line)
+                updated = True
+
         if updated:
             self.updated_fstab_path = os.path.join(self.workdir, "fstab")
             with open(self.updated_fstab_path, "w") as f: