Initrd Size Issues

What is an INITRD?
A small file used to create a small environment inside a ram disk that is used to prepare the system before starting the full system. The main task is to load any drivers needed to mount the rootfs, then mount it and start the system.

More elaborate systems can also run in an intrd/initramfs. For example, the Debian netinstallers run entirely from an initrd image.

see https://wiki.debian.org/initramfs

Why are they used?
Using an initrd/initramfs allows the use of a smaller, more generic kernel by loading any needed kernel modules needed to mount the rootfs from a custom initrd/initramfs rather than compiling every possible disk/filesystem driver into the kernel. This saves on memory which has historically been vital and remains important for embedded systems. It also allows for other complex/dynamic operations such as an installer or recovery environment to operate without disks/etc.

Address passed by Bootloader
On ARM systems the bootloader typically passes the memory address where the initrd/initramfs is loaded inside of a data structure that it passes to the kernel (ATAGs). The kernel typically ignores this if the address is passed via the kernel cmdline ("INITRD=...."). It also passes the size of the initrd/initramfs.

see: http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html#ATAG_INITRD2

set/appended by device-tree
The kernel will include cmdline items that are specified in the "choosen" section of the device tree. To use that command line I believe you must either disable ATAG support (CONFIG_ATAGS) or tell it to merge the ATAG and DTB command line (CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND). I believe the default behavior of CONFIG_ARM_ATAG_DTB_COMPAT is to overwrite the DTB command line.

reduce size by excluding components
The simplest way to make the initrd/initramfs smaller is to limit the kernel modules that are included via configuration:

/usr/share/initramfs-tools/conf.d/modules:

MODULES=dep

Modern versions of initramfs-tools includes a lot of libraries to support features like kernel signing which take up a lot of space and are usually not supported by older embedded devices. There are alternate systems for generating initrd/initramfs that are likely smaller, you can also manually build an even more minimum one though I don't have experience with that currently.

see https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html

reduce size with compression
Debian's initramfs-tool defaults to gzip compression, the size of the initrd/initramfs can be reduced dramatically by switching to XZ compression. This requires a lot more CPU time to compress and a lot more memory to decompress.

The following settings have been found to provide the smallest possible file while still working on devices with as little as 64MB ram.

/usr/share/initramfs-tools/conf.d/compress:

COMPRESS=xz XZ_OPT=-2e export XZ_OPT