Skip to content

A software image is sized from the 4 KiB blocks its tree takes, with an inode table sized to the tree - #564

Draft
DevomB wants to merge 1 commit into
mainfrom
image-sizing-blocks
Draft

DevomB wants to merge 1 commit into
mainfrom
image-sizing-blocks

Conversation

@DevomB

@DevomB DevomB commented Oct 16, 2026

Copy link
Copy Markdown
Owner

A software image is sized from the 4 KiB blocks its tree takes, with an inode table sized to the tree, so an image of many small files fits.

pack_image sized an image from du -sb, the bytes in its tree, plus an eighth and 16 MiB. Since every image is ext4 in 4096-byte blocks (#531), each file takes whole blocks. A tree of 100,000 one-KiB files counts as 100 MiB but needs 390 MiB of blocks, and mke2fs fails with no room. On top of that, mke2fs.conf's small type gives a file system under 512 MiB one inode per 4 KiB: 6.25 % of the image is inode table that a read-only image never fills.

  • The size counts blocks:
    • each file rounded up to 4 KiB;
    • each directory one block at least (no inline data);
    • each symlink of 60 bytes or more one block;
    • then a sixteenth for extent and directory index blocks, 256 bytes an inode, and 16 MiB for the bitmaps, the group descriptors and their copies.
  • make_ext4 takes the inode count as an optional sixth argument (-N): the tree's entries plus an eighth plus 64. The root image passes none, and keeps mke2fs.conf's ratio, as before.
  • Hard links count once per name, and sparse files at their full length. Both overcount, which only leaves room.

Checked: bash -n. The awk was run on a sample of a file of 100 and one of 5000 bytes, directories of 4096, 0 and 12288 bytes, symlinks of 20 and 80 bytes and an empty file: 9 blocks, 8 entries. The images job's own checks still hold: two mke2fs runs give the same image, and the block size is 4096.

The images' own fingerprints (image_inputs in 04-images.sh) do not cover 06-iso.sh, so a cached image build stays current; stage 06 packs anew. Not urgent: today's images fit.

…an inode table sized to the tree

pack_image sized an image from du -sb, the bytes in its tree, plus an eighth and 16 MiB. Every
image is ext4 in 4096-byte blocks, so each file takes whole blocks: a tree of many small files
counted far less than it needs, and mke2fs would fail with no room. And mke2fs.conf's small type
gives a file system under 512 MiB one inode per 4 KiB, a sixteenth of the image in an inode table a
read-only image never fills. The size now counts blocks, with a sixteenth for extent and index
blocks, 256 bytes an inode and 16 MiB for the bitmaps and group descriptors; make_ext4 takes the
inode count, the tree's entries plus an eighth and 64. The root image keeps mke2fs.conf's ratio.
DevomB added a commit that referenced this pull request Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant