Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 420ECCCA470 for ; Fri, 3 Oct 2025 08:31:29 +0000 (UTC) Subject: Difficulties shrinking read-only rootfs image To: yocto@lists.yoctoproject.org From: "Levi Shafter" X-Originating-Location: Denver, Colorado, US (73.169.9.114) X-Originating-Platform: Linux Chrome 140 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Thu, 02 Oct 2025 16:12:17 -0700 Message-ID: Content-Type: multipart/alternative; boundary="rwSREuB6p3XHplnM4SL7" List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 03 Oct 2025 08:31:29 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/65905 --rwSREuB6p3XHplnM4SL7 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, My team and I have been running into issues with reaching better disk utili= zation for our read-only root file system image: root@beaglebone:~# df -h . Filesystem Size Used Avail Use% Mounted on /dev/root 604M 340M 219M 61% / We are building an ext4 image using OpenEmbedded's oe_mkext234fs(), which m= akes use of the mke2fs command to generate the image from the rootfs direct= ory. We then run a resize2fs to try for a disk utilization equal to the sum= of our utilization and 5% of that utilization for root inodes, as we do no= t need additional space for our read-only image. However, our utilization i= s quite small. I tried passing a few options to optimize for our use case: EXTRA_IMAGECMD_ext4 =3D " \ -b 1024 \ -i 65536 \ -m 0 \ -O ^has_journal,^resize,^quota,^dir_index,sparse_super2 \ -E packed_meta_blocks=3D1,num_backup_sb=3D0,lazy_itable_init=3D1,lazy_jo= urnal_init=3D1 \ -L ${IMAGE_NAME} \ This did not improve our utilization much. I also tried adding a pretend to= oe_mkext234fs(), effectively preparing a dynamically sized image before ge= nerating the filesystem from the rootfs directory. While this worked well f= or our more modular builds closer to 225M in size, we still require a safet= y buffer of about 20% for our full-sized image. Otherwise, we get: | Copying files into the device: __populate_fs: Could not allocate block in= ext2 filesystem while writing file "hll" | mkfs.ext4: Could not allocate block in ext2 filesystem while populating f= ile system I am wondering if anyone has experienced similar difficulties, o= r if anyone might have any more ideas. We are planning on moving to a more = appropriate file system such as SquashFS in the future, but we currently re= ly on ext4 for compatibility reasons. --rwSREuB6p3XHplnM4SL7 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Hello,

My team and I have been running into issues with rea= ching better disk utilization for our read-only root file system image:

root@beaglebone:~# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       604M  340M  219M  61% /
We are building an ext4 image using OpenEmbedded's oe_mkext234fs(), wh= ich makes use of the mke2fs command to generate the image from the rootfs d= irectory. We then run a resize2fs to try for a disk utilization equal to th= e sum of our utilization and 5% of that utilization for root inodes, as we = do not need additional space for our read-only image. However, our utilizat= ion is quite small.

I tried passing a few options to optimize fo= r our use case:

EXTRA_IMAGECMD_ext4 =3D " \
    =
-b 1024 \
    =
-i 65536 \<=
/span>
    =
-m 0 \
    =
-O ^has_journal,^resize,^quota,^dir_index,sparse_super2 \
    =
-E packed_meta_blocks=3D1,num_backup_sb=3D0,lazy_itable_init=3D1,lazy_journ=
al_init=3D1 \
    =
-L ${IMAGE_NAME} \

This did not improve our utilization much. I also tried adding a pret= end to oe_mkext234fs(), effectively preparing a dynamically sized image bef= ore generating the filesystem from the rootfs directory. While this worked = well for our more modular builds closer to 225M in size, we still require a= safety buffer of about 20% for our full-sized image. Otherwise, we get:
| Copying files into the device: __pop=
ulate_fs: Could not allocate block in ext2 filesystem while writing file "h=
ll"
| mkfs.ext4: Could not allocate block in ext2 filesystem while populating f=
ile system
I am wondering if anyone has experienced similar difficulties, or if anyone= might have any more ideas. We are planning on moving to a more appropriate= file system such as SquashFS in the future, but we currently rely on ext4 = for compatibility reasons.
--rwSREuB6p3XHplnM4SL7--