wic: obey the rootfs size from the metadata
PATCH 1/1 wic: obey the rootfs size from the metadata
From: Christopher Larson <[email protected]>
When no --size is specified for the rootfs in the .wks, we want to obey the rootfs size from the metadata, otherwise the defined IMAGE_ROOTFS_EXTRA_SPACE and IMAGE_OVERHEAD_FACTOR will not be obeyed. In some cases, this can result in image construction failure, if the size determined by du was insufficient to hold the files without the aforementioned extra space.
This fallback from --size to ROOTFS_SIZE was already implemented when --rootfs-dir is specified in the .wks, but it did not occur otherwise, neither when --rootfs-dir= was passed to wic create nor when IMAGE_ROOTFS was used. This made a certain amount of sense, as this fallback logic happened at such a level that it wasn't able to identify which partitions were rootfs partitions otherwise. Rather than doing it at that level, we can do it in prepare_rootfs(), which is run by the rootfs source plugins.
Note that IMAGE_OVERHEAD_FACTOR and a --overhead-factor in the .wks will now both be applied when --size isn't specified in the .wks. A warning is added about this, though a user won't see it unless wic fails or they examine the do_image_wic log.
Fixes [YOCTO #10815]
--- scripts/lib/wic/partition.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
scripts/lib/wic/partition.py +12 -1
@@ -28,7 +28,7 @@ import os import tempfile from wic.utils.oe.misc import msger, parse_sourceparams -from wic.utils.oe.misc import exec_cmd, exec_native_cmd +from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.plugin import pluginmgr partition_methods = {
@@ -194,6 +194,17 @@ class Partition(): msger.error("File system for partition %s not specified in kickstart, " \ "use --fstype option" % (self.mountpoint)) + # Get rootfs size from bitbake variable if it's not set in .ks file + if not self.size: + # Bitbake variable ROOTFS_SIZE is calculated in + # Image._get_rootfs_size method from meta/lib/oe/image.py + # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, + # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE + rsize_bb = get_bitbake_var('ROOTFS_SIZE') + if rsize_bb: + msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied') + self.size = int(round(float(rsize_bb))) + for prefix in ("ext", "btrfs", "vfat", "squashfs"): if self.fstype.startswith(prefix): method = getattr(self, "prepare_rootfs_" + prefix)
Signature · 1 line
2.8.0
Hi Christopher,
Thank you for the patch!
+1
Quoted 62 lines · Christopher Larson
From: Christopher Larson <[email protected]>
When no --size is specified for the rootfs in the .wks, we want to obey the rootfs size from the metadata, otherwise the defined
IMAGE_ROOTFS_EXTRA_SPACEandIMAGE_OVERHEAD_FACTORwill not be obeyed. In some cases, this can result in image construction failure, if the size determined by du was insufficient to hold the files without the aforementioned extra space.This fallback from --size to
ROOTFS_SIZEwas already implemented when --rootfs-dir is specified in the .wks, but it did not occur otherwise, neither when --rootfs-dir= was passed towic createnor whenIMAGE_ROOTFSwas used. This made a certain amount of sense, as this fallback logic happened at such a level that it wasn't able to identify which partitions were rootfs partitions otherwise. Rather than doing it at that level, we can do it inprepare_rootfs(), which is run by the rootfs source plugins.Note that
IMAGE_OVERHEAD_FACTORand a --overhead-factor in the .wks will now both be applied when --size isn't specified in the .wks. A warning is added about this, though a user won't see it unless wic fails or they examine thedo_image_wiclog.Fixes [YOCTO #10815]
Signed-off-by Christopher Larson <[email protected]>--- scripts/lib/wic/partition.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)scripts/lib/wic/partition.py +12
-1@@ -28,7 +28,7 @@ import os import tempfile from wic.utils.oe.misc import msger, parse_sourceparams -from wic.utils.oe.misc import exec_cmd, exec_native_cmd +from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.plugin import pluginmgr partition_methods = {@@ -194,6 +194,17 @@ class Partition(): msger.error("File system for partition %s not specified in kickstart, " \ "use --fstype option" % (self.mountpoint)) + # Get rootfs size from bitbake variable if it's not set in .ks file + if not self.size: + # Bitbake variable ROOTFS_SIZE is calculated in + # Image._get_rootfs_size method from meta/lib/oe/image.py + # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, + # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE + rsize_bb = get_bitbake_var('ROOTFS_SIZE') + if rsize_bb: + msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied') + self.size = int(round(float(rsize_bb))) + for prefix in ("ext", "btrfs", "vfat", "squashfs"): if self.fstype.startswith(prefix): method = getattr(self, "prepare_rootfs_" + prefix)Signature · 1 line
2.8.0
Signature · 3 lines
-- Regards, Ed
Quoted 6 lines · Ed Bartosh
Hi Christopher,
Thank you for the patch!
+1
Would you be willing to add test case(s) for this functionality to wic selftest module?
Quoted 73 lines · Christopher Larson
Quoted 62 lines
From: Christopher Larson <[email protected]>
When no --size is specified for the rootfs in the .wks, we want to obey the rootfs size from the metadata, otherwise the defined
IMAGE_ROOTFS_EXTRA_SPACEandIMAGE_OVERHEAD_FACTORwill not be obeyed. In some cases, this can result in image construction failure, if the size determined by du was insufficient to hold the files without the aforementioned extra space.This fallback from --size to
ROOTFS_SIZEwas already implemented when --rootfs-dir is specified in the .wks, but it did not occur otherwise, neither when --rootfs-dir= was passed towic createnor whenIMAGE_ROOTFSwas used. This made a certain amount of sense, as this fallback logic happened at such a level that it wasn't able to identify which partitions were rootfs partitions otherwise. Rather than doing it at that level, we can do it inprepare_rootfs(), which is run by the rootfs source plugins.Note that
IMAGE_OVERHEAD_FACTORand a --overhead-factor in the .wks will now both be applied when --size isn't specified in the .wks. A warning is added about this, though a user won't see it unless wic fails or they examine thedo_image_wiclog.Fixes [YOCTO #10815]
Signed-off-by Christopher Larson <[email protected]>--- scripts/lib/wic/partition.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)scripts/lib/wic/partition.py +12
-1@@ -28,7 +28,7 @@ import os import tempfile from wic.utils.oe.misc import msger, parse_sourceparams -from wic.utils.oe.misc import exec_cmd, exec_native_cmd +from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.plugin import pluginmgr partition_methods = {@@ -194,6 +194,17 @@ class Partition(): msger.error("File system for partition %s not specified in kickstart, " \ "use --fstype option" % (self.mountpoint)) + # Get rootfs size from bitbake variable if it's not set in .ks file + if not self.size: + # Bitbake variable ROOTFS_SIZE is calculated in + # Image._get_rootfs_size method from meta/lib/oe/image.py + # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, + # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE + rsize_bb = get_bitbake_var('ROOTFS_SIZE') + if rsize_bb: + msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied') + self.size = int(round(float(rsize_bb))) + for prefix in ("ext", "btrfs", "vfat", "squashfs"): if self.fstype.startswith(prefix): method = getattr(self, "prepare_rootfs_" + prefix)Signature · 1 line
2.8.0Signature · 8 lines
-- Regards, Ed -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 3 lines
-- Regards, Ed