Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mikko Rapeli <mikko.rapeli@linaro.org>
To: openembedded-core@lists.openembedded.org
Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
Subject: [PATCH] wic partition.py: add --apparent-size to du calls
Date: Tue, 27 Feb 2024 13:23:57 +0200	[thread overview]
Message-ID: <20240227112357.2455578-1-mikko.rapeli@linaro.org> (raw)

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



             reply	other threads:[~2024-02-27 11:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 11:23 Mikko Rapeli [this message]
2024-02-27 11:48 ` [OE-core] [PATCH] wic partition.py: add --apparent-size to du calls 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240227112357.2455578-1-mikko.rapeli@linaro.org \
    --to=mikko.rapeli@linaro.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox