You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are opportunities to shrink the Linux kernel image size by adjusting configurations, verified on cortexm-linux.
Disable CONFIG_SYSFS to shed kobject/kset
No userspace in config enumerates /sys, so the entire sysfs attribute infrastructure is pure overhead on a 16MB nommu target.
Add "# CONFIG_SYSFS is not set" to kernel config overrides
Remove /sys mountpoint and sysfs mount from init script
Mount devtmpfs explicitly in /etc/rc (DEVTMPFS_MOUNT=y has no effect
on initramfs roots, so dynamic device nodes need this)
Add post-olddefconfig assertion to catch silent config drift on future
kernel version bumps
Enable CONFIG_BASE_SMALL to shrink core hash table
pid_max drops from 32768 to 4096, and core data structure (dentry cache, inode cache, IDR radix trees) use smaller hash tables. The option is an EXPERT-visible bool.
Set CONFIG_TINY_RCU=y. Minimal RCU implementation for uniprocessor -- smaller than TREE_RCU. Designed for small systems
Set CONFIG_SHMEM=n. Enables the tiny-shmem fallback (ramfs-backed shm), removing the full tmpfs/shmem implementation from the kernel. Saves significant core code on a system that does not need POSIX shared memory.
Disable CONFIG_AUDIT. Kernel auditing framework is irrelevant on a single-user nommu target; drags in audit logging, filter
infrastructure, and syscall audit paths.
Disable CONFIG_SYSVIPC and CONFIG_POSIX_MQUEUE. System V IPC (shmget/semget/msgget) and POSIX message queues are unused by BusyBox; each adds several KB of dead syscall infrastructure.
Disable CONFIG_WATCH_QUEUE, CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_XACCT, CONFIG_TASK_IO_ACCOUNTING. Optional accounting/notification subsystems with no consumer on this target.
CONFIG_BINFMT_SCRIPT (shebang #! interpreter support).
The inittab uses ::sysinit:/bin/sh /etc/rc (explicit shell invocation) and ::respawn:-/bin/sh (FDPIC binary, not a script), so the current boot path does not need kernel shebang handling. BusyBox uses symlink-style applet installation (not script wrappers: CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is disabled in the config). TRADE-OFF: future scripts with #!/bin/sh shebangs will silently fail to exec unless invoked as sh /path/to/script. The cost of BINFMT_SCRIPT is small (~1-2KB). Re-enable if any script in the rootfs needs implicit shebang dispatch.
Audit __init / __initdata annotations in board-level code.
init-only code/data is freed after boot, lowering post-boot RAM footprint. Does not shrink on-disk image but matters on 4MB SSRAM.
Pending:
Syscall table pruning
Selectively disable __SYSCALL entries. Under shared FDPIC linking, libc.so retains wrappers for all supported syscalls regardless of what BusyBox calls, so the kernel-side pruning yields zero benefit. Focus on uClibc feature pruning instead, which removes the libc-side wrappers and reduces the corresponding kernel code reachability via LTO dead-code elimination.
Here are opportunities to shrink the Linux kernel image size by adjusting configurations, verified on cortexm-linux.
Disable
CONFIG_SYSFSto shed kobject/ksetNo userspace in config enumerates /sys, so the entire sysfs attribute infrastructure is pure overhead on a 16MB nommu target.
on initramfs roots, so dynamic device nodes need this)
kernel version bumps
Enable
CONFIG_BASE_SMALLto shrink core hash tablepid_max drops from 32768 to 4096, and core data structure (dentry cache, inode cache, IDR radix trees) use smaller hash tables. The option is an EXPERT-visible bool.
Set
CONFIG_TINY_RCU=y. Minimal RCU implementation for uniprocessor -- smaller than TREE_RCU. Designed for small systemsSet
CONFIG_SHMEM=n. Enables the tiny-shmem fallback (ramfs-backed shm), removing the full tmpfs/shmem implementation from the kernel. Saves significant core code on a system that does not need POSIX shared memory.Disable
CONFIG_AUDIT. Kernel auditing framework is irrelevant on a single-user nommu target; drags in audit logging, filterinfrastructure, and syscall audit paths.
Disable
CONFIG_SYSVIPCandCONFIG_POSIX_MQUEUE. System V IPC (shmget/semget/msgget) and POSIX message queues are unused by BusyBox; each adds several KB of dead syscall infrastructure.Disable
CONFIG_WATCH_QUEUE,CONFIG_TASKSTATS,CONFIG_TASK_DELAY_ACCT,CONFIG_TASK_XACCT,CONFIG_TASK_IO_ACCOUNTING. Optional accounting/notification subsystems with no consumer on this target.CONFIG_BINFMT_SCRIPT(shebang#!interpreter support).The inittab uses
::sysinit:/bin/sh /etc/rc(explicit shell invocation) and::respawn:-/bin/sh(FDPIC binary, not a script), so the current boot path does not need kernel shebang handling. BusyBox uses symlink-style applet installation (not script wrappers:CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERSis disabled in the config). TRADE-OFF: future scripts with#!/bin/shshebangs will silently fail to exec unless invoked assh /path/to/script. The cost of BINFMT_SCRIPT is small (~1-2KB). Re-enable if any script in the rootfs needs implicit shebang dispatch.Audit
__init/__initdataannotations in board-level code.init-only code/data is freed after boot, lowering post-boot RAM footprint. Does not shrink on-disk image but matters on 4MB SSRAM.
Pending:
Selectively disable
__SYSCALLentries. Under shared FDPIC linking,libc.soretains wrappers for all supported syscalls regardless of what BusyBox calls, so the kernel-side pruning yields zero benefit. Focus on uClibc feature pruning instead, which removes the libc-side wrappers and reduces the corresponding kernel code reachability via LTO dead-code elimination.