All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wic partition.py: add --apparent-size to du calls
@ 2024-02-27 11:23 Mikko Rapeli
  2024-02-27 11:48 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 7+ messages in thread
From: Mikko Rapeli @ 2024-02-27 11:23 UTC (permalink / raw)
  To: openembedded-core; +Cc: Mikko Rapeli

If build happens on zfs filesystem with compression enabled,
then image size calculations in do_image_wic task can fail:

output: mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 351999 4k blocks and 176000 inodes
Filesystem UUID: 6091b3a4-ce08-3020-93a6-f755a22ef03b
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Copying files into the device: __populate_fs: Could not allocate block in ext2 filesystem while writing file "service-2.json"
mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system

du --help says:

      --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

du -b already includes --apparent-size.

Same issue reported also in https://lists.yoctoproject.org/g/poky/message/12389

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 scripts/lib/wic/partition.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 795707ec5d..4690ddaa4d 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -254,7 +254,7 @@ class Partition():
                 # Bitbake variable ROOTFS_SIZE is not defined so compute it
                 # from the rootfs_dir size using the same logic found in
                 # get_rootfs_size() from meta/classes/image.bbclass
-                du_cmd = "du -ks %s" % rootfs_dir
+                du_cmd = "du -ks --apparent-size %s" % rootfs_dir
                 out = exec_cmd(du_cmd)
                 self.size = int(out.split()[0])
 
@@ -273,7 +273,7 @@ class Partition():
         """
         Prepare content for an ext2/3/4 rootfs partition.
         """
-        du_cmd = "du -ks %s" % rootfs_dir
+        du_cmd = "du -ks --apparent-size %s" % rootfs_dir
         out = exec_cmd(du_cmd)
         actual_rootfs_size = int(out.split()[0])
 
@@ -349,7 +349,7 @@ class Partition():
         """
         Prepare content for a btrfs rootfs partition.
         """
-        du_cmd = "du -ks %s" % rootfs_dir
+        du_cmd = "du -ks --apparent-size %s" % rootfs_dir
         out = exec_cmd(du_cmd)
         actual_rootfs_size = int(out.split()[0])
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-29  7:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 11:23 [PATCH] wic partition.py: add --apparent-size to du calls Mikko Rapeli
2024-02-27 11:48 ` [OE-core] " Richard Purdie
2024-02-27 11:55   ` Mikko Rapeli
2024-02-27 12:06     ` Richard Purdie
2024-02-27 12:23       ` Mikko Rapeli
2024-02-27 12:33         ` Richard Purdie
2024-02-29  7:30           ` Mikko Rapeli

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.