[PATCH] genericarm64 core-image-initramfs-boot: remove some kernel drivers

Mikko Rapeli
2026-04-10T09:01:16Z

genericarm64 supports a lot of HW and thus large collection of kernel
drivers are enabled and installed to images by default.
Subset of the kernel drivers are needed in initramfs to mount rootfs
from local mass storage devices. This increases initramfs size a lot
and with new kernel config updates even more. Thus remove kernel
drivers from initramfs image which are not needed for mounting
rootfs from local mass storage devices. GPU, Bluetooth, NFC,
sound, networking etc support is not needed in the initramfs.

According to buildhistory core-image-initramfs-boot size is reduced
from 118 to 83 Mb.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
.../images/core-image-initramfs-boot.bbappend | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 meta-yocto-bsp/recipes-core/images/core-image-initramfs-boot.bbappend

diff --git a/meta-yocto-bsp/recipes-core/images/core-image-initramfs-boot.bbappend b/meta-yocto-bsp/recipes-core/images/core-image-initramfs-boot.bbappend
new file mode 100644
index 000000000000..b99fb77f2714
--- /dev/null
+++ b/meta-yocto-bsp/recipes-core/images/core-image-initramfs-boot.bbappend
@@ -0,0 +1,19 @@
+do_rootfs[postfuncs] += "reduce_initrd_size"
+reduce_initrd_size () {
+ # these kernel modules are not needed for rootfs mount from local mass storage
+ # and can be loaded from main rootfs by udev
+ rm -rf \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/bluetooth \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/gpu \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/media \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/net \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/nfc \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/drivers/usb/gadget \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/fs/fuse \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/net/bluetooth \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/net/bridge \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/net/netfilter \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/net/nfc \
+ ${WORKDIR}/rootfs/${libdir}/modules/*/kernel/sound
+}
+
--
2.34.1