Re: [docs] [PATCH] ref-manual/variables.rst: document the INITRAMFS_MAXSIZE variable

Quentin Schulz
2025-04-02T09:15:49Z

Hi Christos,

On 4/1/25 9:43 PM, Christos Gavros via lists.yoctoproject.org wrote:
> hi Quentin,
>
> when you write "compression is enabled", do you mean that the variable "INITRAMFS_FSTYPES" is set to one of the compression formats (by default is set to cpio.gz)?

I mean if the compressed (so not .cpio) size is used or uncompressed
(.cpio).

You may want max size for the compressed size as this is likely the
space it's going to take on the storage medium. You probably are more
interested in the uncompressed size (even for a compressed image!)
because that's the space it's going to take in RAM at runtime.

If I'm not mistaken, even if the initramfs is compressed on the storage
medium, the kernel will uncompress it in RAM before using it.

> If so , then i think that "INITRAMFS_MAXSIZE" applies the compressed image.
>

Reading the introducing commit 155ba626b46bf71acde6c24402fce1682da53b90
in OE-Core, it seems like this was done for limiting the size in RAM.

Reading the code (meta/classes-recipe/image.bbclass:get_rootfs_size()),
it's the size of the IMAGE_ROOTFS directory accounting for an overhead
factor (IMAGE_OVERHEAD_FACTOR) and alignment (IMAGE_ROOTFS_ALIGNMENT).
IMAGE_OVERHEAD_FACTOR variable is explained in code
(meta/conf/bitbake.conf) as some free space for "stuff" to happen at
boot. I am not entirely sure this is necessary for the initramfs (but it
for sure is for rootfs stored on a storage medium). Then this computed
size is compared to the value of INITRAMFS_MAXSIZE. So then it means
this is the uncompressed size we're checking.

What I don't understand is the

"""
# Check the initramfs size against INITRAMFS_MAXSIZE (if set)
if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
"""

check... Why do we care that IMAGE_FSTYPES is equal to INITRAMFS_FSTYPES
in order to check for the initramfs size? What happens when you have
setups with an initramfs AND a rootfs on another medium (e.g. typical
setup for PC distros, or when secureboot is involved (initramfs checking
the rootfs + switch_root))?

Cheers,
Quentin