Busybox - applets included in OpenWrt images and builds

Over the last couple of years, OpenWrt images have grown considerably in size - software has become more featureful (and sometimes also bloated ;)), and advances in terms of security/cryptography-enabled protocols have made the inclusion of formerly optional libraries essential. This has also, in my opinion, somewhat shifted the concern about how much space the base system's userland may consume, since it is now a smaller fraction of the whole - mostly because the other things grew more than all the busybox-provided coreutils replacements and tools did.

Since OpenWrt is spending quite a few more bytes on certain important stuff today, I've been wondering if it would be prudent to spend an (insignificant, I would hope) additional amount of bytes on other handy stuff that would provide a more feature-rich environment for scripts and users to depend on on OpenWrt platforms, by shipping additional busybox components/applets that have not been included so far.

There's a number of those overlooked busybox applets that I would personally find worthwhile that probably would not bloat the generated images by a noticable amount. I would consider at least the following (in no particular order):

  • pkill
  • chpst
  • watch
  • timeout
  • nmeter
  • makemime
  • comm
  • diff
  • findfs
  • fold
  • fuser
  • inotifyd
  • ionice
  • lzop
  • lzopcat
  • mountpoint
  • pscan
  • realpath
  • split
  • stat
  • tac
  • watchdog

For a list of all applets and a short description for most, check the BusyBox docs.

What's your opinion on the matter? Would the impact be acceptable? If not, were's a good tradeoff to be had?

Is there really no need felt for any additional busybox applets to be included in the default OpenWrt userland?

I would vote for diff and watch.

Would you care to build a busybox with those applets included and compare the size? Your request might gain more traction if supported by evidence.

2 Likes

pkill, watch, timeout, com, diff, findfs, fold, fuser, ionice, realpath, split, stat, and tac are all currently available to anyone as standalone utilities. Those with the storage space and desire can simply use them. I had never heard of nmeter before but htop/atop/btop are available in the repository and seem eminently suitable.

The one item in the list that I see having wide application is watchdog. In fact, I'd like to go a step further and see a luci interface for it. Since kmod-softdog is supported, there is no real way to use it since watchdog isn't included as a busybox or a standalone tool.

2 Likes

You can already toggle the required busybox features on for your own image when you build your own image from sources.

It is also good to remember that many busybox apps are somewhat feature-limited and do not offer quite the same functionality as the full utilities. So, using the separate "full apps" might still be desireable for power users.

3 Likes

So I spent some time browsing 23.05's menucondig today to hunt for some (NB: this is not exhaustive and does not match with my initially proposed list 100%) of the busybox applets I listed, and ended up with this diff against the current OpenWrt "vanilla" configuration related to it:

--- .config     2023-07-19 17:47:02.648344688 +0200
+++ .config.old 2023-07-19 17:47:43.132598308 +0200
@@ -1806 +1806 @@
-CONFIG_BUSYBOX_CONFIG_REALPATH=y
+# CONFIG_BUSYBOX_CONFIG_REALPATH is not set
@@ -1818,3 +1818 @@
-CONFIG_BUSYBOX_CONFIG_STAT=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FORMAT=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FILESYSTEM=y
+# CONFIG_BUSYBOX_CONFIG_STAT is not set
@@ -1826 +1824 @@
-CONFIG_BUSYBOX_CONFIG_TAC=y
+# CONFIG_BUSYBOX_CONFIG_TAC is not set
@@ -1835 +1833 @@
-CONFIG_BUSYBOX_CONFIG_TIMEOUT=y
+# CONFIG_BUSYBOX_CONFIG_TIMEOUT is not set
@@ -1910,3 +1908 @@
-CONFIG_BUSYBOX_CONFIG_DIFF=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
-CONFIG_BUSYBOX_CONFIG_FEATURE_DIFF_DIR=y
+# CONFIG_BUSYBOX_CONFIG_DIFF is not set
@@ -2080 +2076 @@
-CONFIG_BUSYBOX_CONFIG_IONICE=y
+# CONFIG_BUSYBOX_CONFIG_IONICE is not set
@@ -2107 +2103 @@
-CONFIG_BUSYBOX_CONFIG_MOUNTPOINT=y
+# CONFIG_BUSYBOX_CONFIG_MOUNTPOINT is not set
@@ -2217,2 +2213 @@
-CONFIG_BUSYBOX_CONFIG_WATCHDOG=y
-# CONFIG_BUSYBOX_CONFIG_FEATURE_WATCHDOG_OPEN_TWICE is not set
+# CONFIG_BUSYBOX_CONFIG_WATCHDOG is not set
@@ -2293 +2288 @@
-CONFIG_BUSYBOX_CONFIG_PSCAN=y
+# CONFIG_BUSYBOX_CONFIG_PSCAN is not set
@@ -2357 +2352 @@
-CONFIG_BUSYBOX_CONFIG_FUSER=y
+# CONFIG_BUSYBOX_CONFIG_FUSER is not set
@@ -2364 +2359 @@
-CONFIG_BUSYBOX_CONFIG_NMETER=y
+# CONFIG_BUSYBOX_CONFIG_NMETER is not set
@@ -2366 +2361 @@
-CONFIG_BUSYBOX_CONFIG_PKILL=y
+# CONFIG_BUSYBOX_CONFIG_PKILL is not set
@@ -2388 +2383 @@
-CONFIG_BUSYBOX_CONFIG_WATCH=y
+# CONFIG_BUSYBOX_CONFIG_WATCH is not set
@@ -2394 +2389 @@
-CONFIG_BUSYBOX_CONFIG_CHPST=y
+# CONFIG_BUSYBOX_CONFIG_CHPST is not set

This amounts to the following additional busybox applets becoming available:

  • realpath
  • stat
  • tac
  • timeout
  • diff
  • ionice
  • mountpoint
  • watchdog
  • pscan
  • fuser
  • nmeter
  • pkill
  • watch
  • chpst

Final stripped executable size of my x86_64 build without these applets (aka "OpenWrt Vanilla Edition busybox"): 398K
Final stripped executable size of my x86_64 build with these applets (aka "OpenWrt Enhanced Edition busybox"): 422K

I am not sure how squashfsification would affects the total impact on space consumption, but I would argue that a measly 24K (less than 1.8K per applet/utility on average) is probably small enough to warrant further discussion.

While looking at this in more detail, I discovered a number of promising optional busybox features that come with virtually no binary size increase at all (according to the help text at least) that, I think, should also be revisited and considered for being set for official images. I will follow up with a list once temperatures around here allow me to think again :wink: :sweat_smile:

1 Like

Sounds like a beginning of a successful PR. :wink:

Let's see about that - I just submitted https://github.com/openwrt/openwrt/pull/13149 and hope at least parts of it will be deemed useful :slight_smile: