Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:additional-software:saving_space [2020/09/30 13:59] – [Excluding packages] add internal links to LuCI row pcryan | docs:guide-user:additional-software:saving_space [2021/03/03 07:12] – header levels vgaetera | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Saving firmware space ====== | + | ====== Saving firmware space and RAM ====== |
| ===== Excluding packages ===== | ===== Excluding packages ===== | ||
| - | Flash space is scarce on devices with only 4MB flash. You can save some space while compiling your own image (e.g. with the [[docs: | + | Flash space is scarce on devices with only 4MB flash. |
| - | In order to completely remove IPv6 support and related packages you also need to ask the imagebuilder to do so by also passing this option to the make command: | + | You can save some space while compiling your own image (e.g. with the [[docs: |
| + | In order to completely remove IPv6 support and related packages you also need to ask the imagebuilder to do so by also passing this option to the make command: | ||
| - | ^ Action | + | ^ Action ^ Packages ^ Menu path ^ |
| - | | remove pppoe | + | | remove pppoe | '' |
| - | | remove IPv6 | '' | + | | remove IPv6 | '' |
| - | | remove dhcp server | + | | remove dhcp server | '' |
| - | | remove | + | | remove iptables | '' |
| - | | remove opkg | '' | + | | remove opkg | '' |
| - | | add LuCI minimal | + | | add LuCI minimal | '' |
| - | | | '' | + | | | '' |
| - | | | '' | + | | | '' |
| - | | add zram¹ | + | | add zram | '' |
| - | ¹ Note: Do not use zram-swap for 4MB flash devices as it // | + | :!: Do not use zram-swap for 4MB flash devices as it // |
| + | It is listed here as it is helpful on machines with very little RAM memory. | ||
| + | :?: The minus '' | ||
| ==== Build image for devices with only 4MB flash ==== | ==== Build image for devices with only 4MB flash ==== | ||
| + | **Example image builder command line** | ||
| - | **Example image builder command line**\\ | + | **Note:** In the command line shown below, you need to adjust '' |
| - | **Note:** In the command line shown below, you need to adjust '' | + | Use '' |
| - | ^ LuCI ^ Action ^ Imagebuilder commandline ^ | + | ^ LuCI ^ Action ^ Imagebuilder commandline ^ |
| | with LuCI | - remove pppoe and IPv6\\ + include only needed luci components, not full luci package. | '' | | with LuCI | - remove pppoe and IPv6\\ + include only needed luci components, not full luci package. | '' | ||
| - | PACKAGES=" | + | PACKAGES=" |
| - | -ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only"'' | + | luci-app-firewall luci-mod-admin-full luci-theme-bootstrap \ |
| - | | without LuCI | - remove pppoe and IPv6 | '' | + | -ppp -ppp-mod-pppoe -ip6tables -odhcp6c |
| + | -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only"'' | ||
| + | | without LuCI | - remove pppoe and IPv6 | '' | ||
| + | PACKAGES=" | ||
| + | -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only"'' | ||
| Resources: | Resources: | ||
| Line 36: | Line 43: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * Talk [[https:// | ||
| ==== Build image for devices with only 16/32MB RAM ==== | ==== Build image for devices with only 16/32MB RAM ==== | ||
| - | |||
| If the device has 16MB or less of RAM, then it should only be used as Internal AP (e.g. to extend Wi-Fi coverage).\\ | If the device has 16MB or less of RAM, then it should only be used as Internal AP (e.g. to extend Wi-Fi coverage).\\ | ||
| - | **Example image builder command line**\\ | + | **Example image builder command line** |
| - | **Note:** In the command line shown below, you need to adjust '' | + | |
| - | ^ RAM | + | **Note:** In the command line shown below, you need to adjust '' |
| - | | 16MB | - remove pppoe and IPv6\\ - remove all related elements to iptables\\ - remove dhcp servers \\ + add LUCI\\ + add zram-swap\\ - remove opkg - not needed after making these adjustments | '' | + | Use '' |
| - | PACKAGES=" | + | |
| - | -ppp -ppp-mod-pppoe -iptables -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only -odhcpd -opkg"'' | + | ^ RAM ^ Action ^ Imagebuilder commandline ^ |
| - | | 32MB | - remove pppoe and IPv6\\ + add LUCI\\ + add zram-swap\\ - remove opkg - not needed after making these adjustments | '' | + | | 16MB | - remove pppoe and IPv6\\ - remove all related elements to iptables\\ - remove dhcp servers \\ + add LUCI\\ + add zram-swap\\ - remove opkg - not needed after making these adjustments | '' |
| - | PACKAGES=" | + | PACKAGES=" |
| - | -ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only -opkg"'' | + | luci-base luci-app-firewall luci-mod-admin-full |
| + | luci-theme-bootstrap zram-swap \ | ||
| + | -ppp -ppp-mod-pppoe -iptables -ip6tables -odhcp6c -kmod-ipv6 | ||
| + | -kmod-ip6tables -odhcpd-ipv6only -odhcpd -opkg"'' | ||
| + | | 32MB | - remove pppoe and IPv6\\ + add LUCI\\ + add zram-swap\\ - remove opkg - not needed after making these adjustments | '' | ||
| + | PACKAGES=" | ||
| + | luci-app-firewall luci-mod-admin-full luci-theme-bootstrap zram-swap \ | ||
| + | -ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 | ||
| + | -kmod-ip6tables -odhcpd-ipv6only -opkg"'' | ||
| Resources: | Resources: | ||
| Line 58: | Line 72: | ||
| ===== Making all kernel modules built-in ===== | ===== Making all kernel modules built-in ===== | ||
| - | |||
| This option compiles the kernel modules inside the kernel, you can either pick what modules you think can be integrated and make them built-in by pressing " | This option compiles the kernel modules inside the kernel, you can either pick what modules you think can be integrated and make them built-in by pressing " | ||
| Line 71: | Line 84: | ||
| His comments: | His comments: | ||
| - | //I did a quick experiment of this and **instead of saving 4k, my *image* is a full 256k smaller**. | + | //I did a quick experiment of this and **instead of saving 4k, my *image* is a full 256k smaller**. |
| + | I haven' | ||
| + | Further, modules inherently have greater overhead, even after __init sections have been discarded. | ||
| - | The only downside is that built-ins cannot be unloaded and will always occupy a portion of RAM. But having them built into the kernel is far more efficient.// | + | The only downside is that built-ins cannot be unloaded and will always occupy a portion of RAM. |
| + | But having them built into the kernel is far more efficient.// | ||
| - | (The " | + | (The " |
| + | See, for example '' | ||
| In a follow up mail by Phillip Prindeville pointed out the main drawback of this method. | In a follow up mail by Phillip Prindeville pointed out the main drawback of this method. | ||
| - | //Some hardware (it’s rare but not unheard of) can only be reset by unloading and reloading the module that controls it. Otherwise, you have to reboot the box. If you build all of your drivers in, then rebooting is all you have.// | + | //Some hardware (it’s rare but not unheard of) can only be reset by unloading and reloading the module that controls it. |
| + | Otherwise, you have to reboot the box. | ||
| + | If you build all of your drivers in, then rebooting is all you have.// | ||
| ===== Modifying build configuration variables ===== | ===== Modifying build configuration variables ===== | ||
| + | You can also save space by changing configuration variables using '' | ||
| + | In addition to the ones mentioned here you can save a tiny bit of space by disabling commands in busybox. | ||
| - | You can also save space by changing configuration variables using '' | + | ==== Saving space ==== |
| + | ^ Config variable\\ ('' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| - | === Options that can be disabled | + | :!: Block size must be a power of 2, between 4096 bytes and 1 Megabyte. 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 | + | :!: To **build a kernel that only works with a specific device**, run '' |
| - | | CONFIG_KERNEL_PRINTK | + | [[https://forum.openwrt.org/t/building-a-smaller-kernel-for-a-specific-device/30370/8|This can save some disk space and RAM]]. |
| - | | CONFIG_KERNEL_CRASHLOG | + | |
| - | | CONFIG_KERNEL_SWAP | + | |
| - | | CONFIG_KERNEL_KALLSYMS | + | |
| - | | CONFIG_KERNEL_DEBUG_INFO | Global build settings | + | |
| - | | CONFIG_KERNEL_ELF_CORE | + | |
| - | | CONFIG_IPV6 | + | |
| - | | CONFIG_KERNEL_MAGIC_SYSRQ | Global build settings / Kernel build options / Compile the kernel | + | |
| - | | CONFIG_KERNEL_PRINTK_TIME | Global build settings | + | |
| - | | CONFIG_PACKAGE_MAC80211_DEBUGFS | Kernel modules / Wireless Drivers / kmod-mac80211 / Export mac80211 internals in DebugFS | 21 KB | | + | |
| - | | CONFIG_PACKAGE_MAC80211_MESH | + | |
| - | === Options that can be enabled to save space: | + | ==== Saving RAM ==== |
| - | + | ^ Config variable\\ ('' | |
| - | ^ Config variable | + | | '' |
| - | | CONFIG_STRIP_KERNEL_EXPORTS | Global build settings / Strip unnecessary exports from the kernel image | | + | | '' |
| - | | CONFIG_USE_MKLIBS | + | | '' |
| - | + | ||
| - | === '' | + | |
| - | + | ||
| - | ^ Config variable | + | |
| - | | CONFIG_SERIAL_8250 | Device Drivers / Character devices / Serial drivers / 8250/16550 and compatible serial support | This will also save RAM by preventing / | + | |
| - | | CONFIG_EARLY_PRINTK | Kernel hacking / Early printk | | + | |
| - | + | ||
| - | <WRAP center round info 60%> | + | |
| - | To **build a kernel that only works with a specific device**, run '' | + | |
| - | </ | + | |
| - | + | ||
| - | === Increase block size from the default 256 KB to improve compression: | + | |
| - | + | ||
| - | ^ Config variable ^ Menu path ^ | + | |
| - | | TARGET_SQUASHFS_BLOCK_SIZE | Target Images / squashfs / Block size | | + | |
| - | <WRAP center round important 60%> | + | |
| - | Block size must be a power of 2, between 4096 bytes and 1 Megabyte. | + | |
| - | </ | + | |
| - | <WRAP center round alert 60%> | + | |
| - | **Warning**: | + | |
| - | </ | + | |
| - | + | ||
| - | === Options that can be enabled to save RAM: === | + | |
| - | + | ||
| - | ^ Config variable | + | |
| - | | PACKAGE_zram-swap | Base system / zram-swap | | + | |
| - | | PROCD_ZRAM_TMPFS | + | |
| - | + | ||
| - | === Reduce the number of cached blocks by running | + | |
| - | + | ||
| - | ^ Config variable ^ Menu path ^ | + | |
| - | | KERNEL_SQUASHFS_FRAGMENT_CACHE_SIZE | + | |
| ===== Replace LuCI icons with a blank pixel ===== | ===== Replace LuCI icons with a blank pixel ===== | ||
| - | + | The icons in LuCI are not strictly necessary and replacing them with a blank image will save about 15 KB. | |
| - | The icons in LuCI are not strictly necessary and replacing them with a blank image will save about 15 KB. This bash script will take an OpenWrt git path as parameter and replace the images with a blank using the [[docs: | + | This bash script will take an OpenWrt git path as parameter and replace the images with a blank using the [[docs: |
| < | < | ||