All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH] image.bbclass: fix rootfs size computation
@ 2020-07-23 12:26 Sumit Garg
  0 siblings, 0 replies; only message in thread
From: Sumit Garg @ 2020-07-23 12:26 UTC (permalink / raw)
  To: openembedded-core; +Cc: richard.purdie, daniel.thompson, Sumit Garg

Currently we rely on disk usage to compute rootfs size that may vary
depending on build machine filesystem type.

Consider following case:

Build machine 1: ext4 filesystem:

$ du -ks tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/
403024	tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/

Build machine 2: zfs filesystem:

$ du -ks tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/
240353	tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/

So, this leads to build failures during ext4 image creation on build
machine 2 as allocated ext4 image size is less than what is actually
required.

In order to fix this we need to rely on "--apparent-size" option
provided by "du" utility that provides the actual size. See below usage
text:

$ du --help
<snip>
Mandatory arguments to long options are mandatory for short options too.
  -0, --null            end each output line with NUL, not newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
<snip>

With option "--apparent-size":

Build machine 1: ext4 filesystem:

$ du -ks --apparent-size tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/
379576	tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/

Build machine 2: zfs filesystem:

$ du -ks --apparent-size tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/
377455	tmp-rpb-glibc/work/qemuarm64-linaro-linux/rpb-console-image/1.0-r0/rootfs/

Although there is still little difference in actual reported size but
that can very well be covered by IMAGE_OVERHEAD_FACTOR.

Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
 meta/classes/image.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 3b5600e..bf0685f 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -516,7 +516,7 @@ def get_rootfs_size(d):
     initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
     initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
 
-    output = subprocess.check_output(['du', '-ks',
+    output = subprocess.check_output(['du', '-ks', '--apparent-size',
                                       d.getVar('IMAGE_ROOTFS')])
     size_kb = int(output.split()[0])
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-23 12:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 12:26 [meta-oe][PATCH] image.bbclass: fix rootfs size computation Sumit Garg

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.