Discussion about what can be removed/disabled/shrunk in images

There is https://openwrt.org/faq/before_installation#which_packages_can_i_safely_remove_to_save_space, but it's also possible to do some extra tweaking using make menuconfig and make kernel_menuconfig. I have been testing various settings with my Asus RT-N56U. Here is a list of things I have disabled seemingly without breaking anything:

Global build settings / Kernel build options / Crash logging
CONFIG_KERNEL_CRASHLOG
Global build settings / Kernel build options / Support for paging of anonymous memory (swap)
CONFIG_KERNEL_SWAP
Global build settings / Kernel build options / Compile the kernel with symbol table information
CONFIG_KERNEL_KALLSYMS
Global build settings / Kernel build options / Compile the kernel with debug information
CONFIG_KERNEL_DEBUG_INFO
CONFIG_KERNEL_DEBUG_KERNEL (unset by disabling CONFIG_KERNEL_INFO)
Global build settings / Kernel build options / Enable process core dump support
CONFIG_KERNEL_ELF_CORE
CONFIG_KERNEL_COREDUMP (unset by disabling CONFIG_KERNEL_ELF_CORE)
Global build settings / Kernel build options / Compile the kernel with SysRq support
KERNEL_MAGIC_SYSRQ
Kernel modules / Wireless Drivers / kmod-mac80211 / Export mac80211 internals in DebugFS
PACKAGE_MAC80211_DEBUGFS
Kernel modules / Wireless Drivers / kmod-mac80211 / Enable 802.11s mesh support
PACKAGE_MAC80211_MESH

I also tested disabling printk, but the kernel log disappeared completely, and disabling kernel debug fs made the overlay file system disappear so it used a temporary RAM FS instead.

Things that can be enabled to save space:

Global build settings / Strip unnecessary exports from the kernel image
CONFIG_STRIP_KERNEL_EXPORTS=y
Global build settings / Strip unnecessary functions from libraries
CONFIG_USE_MKLIBS=y

On systems with little RAM it may help to enable these:

Base system
PACKAGE_zram-swap
Base system / procd Configuration
PROCD_ZRAM_TMPFS

Increase block size to improve compression:

Target Images / squashfs / Block size
TARGET_SQUASHFS_BLOCK_SIZE=256

If you are low on RAM you should also run make kernel_menuconfig and set fragments cached = 1, especially if you increased the block size.

File systems / Miscellaneous filesystems / Additional option for memory-constrained systems / Number of fragments cached
SQUASHFS_EMBEDDED=y
CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=1

The savings aren't radical. Maybe 100-300 KB in total, but sometimes that's what's needed. I hope others will add their suggestions about what can be removed or information about what bad may happen if you do. Maybe I'll write a separate wiki page about optimizations later.

1 Like

hy I tried everything here and there was an error on the wiki when I disabled CONFIG_PACKAGE_MAC80211_DEBUGFS

 warning Please enable ATH10K-DEBUGFS kernel option for optimal support for CT firmware.

Openwrt 19.07.0-rc1

do you how to fix it

root@wndr3700:~# mkdir /tmp/prerm
root@wndr3700:~# cp /rom/usr/lib/opkg/info/*prerm /tmp/prerm/
root@wndr3700:~# du -chs /tmp/prerm/

392.0K	/tmp/prerm/

Use the "normal" firmware instead of the Candela Technologies (CT). I don't recommend doing it at all, and would suggest to enable the requested feature instead.

there is a big problem I have done like on the wiki and in this forum, I have made it and succeeded in continuing my flash to the router and it was not as sweet as I hoped, the router was experiencing failsafe mode. I followed the instructions on the wiki and in this forum Modifying build configuration variables

Modifying build configuration variables

You can also save space by changing configuration variables using make menuconfig. In addition to the ones mentioned here you can save a tiny bit of space by disabling commands in busybox.

Options that can be disabled to save space.

Config variable	Menu path	Estimated savings
CONFIG_KERNEL_PRINTK	Global build settings / Kernel build options / Enable support for printk	
CONFIG_KERNEL_CRASHLOG	Global build settings / Kernel build options / Crash logging	
CONFIG_KERNEL_SWAP	Global build settings / Kernel build options / Support for paging of anonymous memory (swap)	
CONFIG_KERNEL_KALLSYMS	Global build settings / Kernel build options / Compile the kernel with symbol table information	
CONFIG_KERNEL_DEBUG_INFO	Global build settings / Kernel build options / Compile the kernel with debug information	
CONFIG_KERNEL_ELF_CORE	Global build settings / Kernel build options / Enable process core dump support	
CONFIG_IPV6	Global build settings / Enable IPv6 support in packages	
CONFIG_KERNEL_MAGIC_SYSRQ	Global build settings / Kernel build options / Compile the kernel with SysRq support	
CONFIG_KERNEL_PRINTK_TIME	Global build settings / Kernel build options / Enable printk timestamps	
CONFIG_PACKAGE_MAC80211_DEBUGFS	Kernel modules / Wireless Drivers / kmod-mac80211 / Export mac80211 internals in DebugFS	21 KB
CONFIG_PACKAGE_MAC80211_MESH	Kernel modules / Wireless Drivers / kmod-mac80211 / Enable 802.11s mesh support	29 KB
Options that can be enabled to save space.

Config variable	Menu path
CONFIG_STRIP_KERNEL_EXPORTS	Global build settings / Strip unnecessary exports from the kernel image
CONFIG_USE_MKLIBS	Global build settings / Strip unnecessary functions from libraries
make kernel_menuconfig options that can save space.

Config variable	Menu path	Comments
CONFIG_SERIAL_8250	Device Drivers / Character devices / Serial drivers / 8250/16550 and compatible serial support	This will also save RAM by preventing /sbin/askfirst from running
CONFIG_EARLY_PRINTK	Kernel hacking / Early printk	
To build a kernel that only works with a specific device, run make kernel_menuconfig CONFIG_TARGET=subtarget to edit  target/linux/<platform>/*/config-default and go to  Machine selection / <Platform> machine selection and disable all devices except for the specific device. This can save some disk space and RAM.

Increase block size from the default 256 KB to improve compression. Warning: By default 3 blocks will be cached so this will also make the router use more RAM (if 3 blocks are cached, and a block size of 1024 KB is used, this will use 2,304 KB more RAM (3 * 1024 KB - 3 * 256 KB)). It may also make the router use more CPU to decompress the larger blocks.

Config variable	Menu path
TARGET_SQUASHFS_BLOCK_SIZE	Target Images / squashfs / Block size
Options that can be enabled to save RAM.

Config variable	Menu path
PACKAGE_zram-swap	Base system
PROCD_ZRAM_TMPFS	Base system / procd Configuration
Reduce the number of cached blocks by running make kernel_menuconfig.

Config variable	Menu path
CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE	File systems / Miscellaneous filesystems / Additional option for memory-constrained systems / Number of fragments cached