[2/2] isoimage-isohybrid-isar: fix disk full if no initrd exists

Message ID 20251126114431.20236-2-Quirin.Gylstorff@siemens.com
State Accepted, archived
Headers show
Series [1/2] isoimage-isohybrid-isar: fix error if source_param image_name is set | expand

Commit Message

Quirin Gylstorff Nov. 26, 2025, 11:43 a.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

If no initrd was generated during the rootfs build the wic plugin
uses the existing rootfs as initrd. The plugin uses shutil.copytree
to copy the rootfs to a new folder. As the rootfs contains `/dev/full`
this will fill the disk until it is full.

To avoid this error ignore all files in `/dev/` of the rootfs.

Tested-by:    Herbert Bernecker <herbert.bernecker@siemens.com>
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 .../lib/wic/plugins/source/isoimage-isohybrid-isar.py     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Quirin Gylstorff Nov. 27, 2025, 11:10 a.m. UTC | #1
On 11/26/25 12:43, 'Quirin Gylstorff' via isar-users wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> If no initrd was generated during the rootfs build the wic plugin
> uses the existing rootfs as initrd. The plugin uses shutil.copytree
> to copy the rootfs to a new folder. As the rootfs contains `/dev/full`
> this will fill the disk until it is full.
> 
> To avoid this error ignore all files in `/dev/` of the rootfs.
> 
> Tested-by:    Herbert Bernecker <herbert.bernecker@siemens.com>
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
/dev should be populate by mmdebstrap so another way should be
--skip=output/mknod or  --skip=output/dev  but during the initial
testing these option broke package builds.

Quirin

>   .../lib/wic/plugins/source/isoimage-isohybrid-isar.py     | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
> index 690e291e..fb6c6b39 100644
> --- a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
> +++ b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
> @@ -203,8 +203,14 @@ class IsoImagePlugin(SourcePlugin):
>               # Create initrd from rootfs directory
>               initrd = "%s/initrd.cpio.gz" % cr_workdir
>               initrd_dir = "%s/INITRD" % cr_workdir
> +            def ignore_contents(src, names):
> +                if os.path.basename(src) == 'dev':
> +                    return names
> +                return []
> +
>               shutil.copytree("%s" % rootfs_dir, \
> -                            "%s" % initrd_dir, symlinks=True)
> +                            "%s" % initrd_dir, \
> +                            ignore=ignore_contents, symlinks=True)
>   
>               if os.path.isfile("%s/init" % rootfs_dir):
>                   shutil.copy2("%s/init" % rootfs_dir, "%s/init" % initrd_dir)
Zhihang Wei Nov. 28, 2025, 9:02 a.m. UTC | #2
On 11/27/25 12:10, 'Quirin Gylstorff' via isar-users wrote:
>
>
> On 11/26/25 12:43, 'Quirin Gylstorff' via isar-users wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> If no initrd was generated during the rootfs build the wic plugin
>> uses the existing rootfs as initrd. The plugin uses shutil.copytree
>> to copy the rootfs to a new folder. As the rootfs contains `/dev/full`
>> this will fill the disk until it is full.
>>
>> To avoid this error ignore all files in `/dev/` of the rootfs.
>>
>> Tested-by:    Herbert Bernecker <herbert.bernecker@siemens.com>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
> /dev should be populate by mmdebstrap so another way should be
> --skip=output/mknod or  --skip=output/dev  but during the initial
> testing these option broke package builds.
>
> Quirin
>
This patch has passed CI and LGTM. We'll merge this by end of this 
workday if no more discussion is coming.

Zhihang
>> .../lib/wic/plugins/source/isoimage-isohybrid-isar.py     | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git 
>> a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py 
>> b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
>> index 690e291e..fb6c6b39 100644
>> --- a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
>> +++ b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
>> @@ -203,8 +203,14 @@ class IsoImagePlugin(SourcePlugin):
>>               # Create initrd from rootfs directory
>>               initrd = "%s/initrd.cpio.gz" % cr_workdir
>>               initrd_dir = "%s/INITRD" % cr_workdir
>> +            def ignore_contents(src, names):
>> +                if os.path.basename(src) == 'dev':
>> +                    return names
>> +                return []
>> +
>>               shutil.copytree("%s" % rootfs_dir, \
>> -                            "%s" % initrd_dir, symlinks=True)
>> +                            "%s" % initrd_dir, \
>> +                            ignore=ignore_contents, symlinks=True)
>>                 if os.path.isfile("%s/init" % rootfs_dir):
>>                   shutil.copy2("%s/init" % rootfs_dir, "%s/init" % 
>> initrd_dir)
>

Patch

diff --git a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
index 690e291e..fb6c6b39 100644
--- a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py
@@ -203,8 +203,14 @@  class IsoImagePlugin(SourcePlugin):
             # Create initrd from rootfs directory
             initrd = "%s/initrd.cpio.gz" % cr_workdir
             initrd_dir = "%s/INITRD" % cr_workdir
+            def ignore_contents(src, names):
+                if os.path.basename(src) == 'dev':
+                    return names
+                return []
+
             shutil.copytree("%s" % rootfs_dir, \
-                            "%s" % initrd_dir, symlinks=True)
+                            "%s" % initrd_dir, \
+                            ignore=ignore_contents, symlinks=True)
 
             if os.path.isfile("%s/init" % rootfs_dir):
                 shutil.copy2("%s/init" % rootfs_dir, "%s/init" % initrd_dir)