classes-recipe/image: Add variable to create rootfs with a exact size
PATCH 1/1 classes-recipe/image: Add variable to create rootfs with a exact size
From: Fabio Berton <[email protected]>
Add the IMAGE_ROOTFS_EXACT_SIZE variable to allow the creation of a root filesystem with an exact size as specified by the user. This bypasses the default size calculation done by the get_rootfs_size function.
This feature is useful for creating a small ext4 filesystem with a block size of 1k. The get_rootfs_size function uses a block size of 4k to determine the size of IMAGE_ROOTFS, which may be larger than the value set in IMAGE_ROOTFS_SIZE. If an ext4 rootfs with a block size of 1K is nearly full, the .ext4 file generated by Yocto will be larger than expected due to the way get_rootfs_size calculates the size.
By using IMAGE_ROOTFS_EXACT_SIZE, users can specify the exact size required. Users should ensure that the size is set correctly according to the filesystem requirements. It is not easy to predict the block size that is used by a filesystem because it can be set by a parameter or it can be added automatically by the tool that creates the file system.
--- meta/classes-recipe/image.bbclass | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
meta/classes-recipe/image.bbclass +9 -4
@@ -132,7 +132,7 @@ python () { def rootfs_variables(d): from oe.rootfs import variable_depends - variables = ['IMAGE_DEVICE_TABLE','IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE', + variables = ['IMAGE_DEVICE_TABLE','IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE', 'IMAGE_ROOTFS_EXACT_SIZE', 'IMAGE_ROOTFS_EXTRA_SPACE', 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', 'IMAGE_LINGUAS_COMPLEMENTARY', 'IMAGE_LOCALES_ARCHIVE', 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS', 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
@@ -596,9 +596,14 @@ def get_rootfs_size(d): return base_size python set_image_size () { - rootfs_size = get_rootfs_size(d) - d.setVar('ROOTFS_SIZE', str(rootfs_size)) - d.setVarFlag('ROOTFS_SIZE', 'export', '1') + rootfs_size = d.getVar('IMAGE_ROOTFS_EXACT_SIZE') + # If IMAGE_ROOTFS_EXACT_SIZE variable is not set, use the result of + # get_rootfs_size as ROOTFS_SIZE. + if not rootfs_size: + rootfs_size = str(get_rootfs_size(d)) + + d.setVar('ROOTFS_SIZE', rootfs_size) + d.setVarFlag('ROOTFS_SIZE', 'export', '1') } #
Signature · 1 line
2.49.0
Hi,
Any thoughts on this?
Regards,
Fabio
Gentle ping