Busybox
Home Firmware tools memory stick Busybox easy VI Packages Miscellaneous Update Upgrade Error: killed Slug 2010 Beyond NSLU2 Contents Site home

 

The Busybox multi-utility program

When reading about openslug and unslung the name busybox turns up repeatedly. It's important to know what busybox is (and isn't) if you are going to do anything more sophisticated than install a few packages and leave it at that.

BusyBox v1.01 (2006.06.09-14:27+0000) multi-call binary

Usage: busybox [function] [arguments]...
or: [function] [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!

Currently defined functions:
[, ar, ash, awk, basename, bunzip2, busybox, bzcat, cat, chgrp,
chmod, chown, chroot, clear, cp, cut, date, dd, df, dirname, dmesg,
du, echo, egrep, env, expr, false, fdisk, fgrep, free, getkey,
grep, gunzip, gzip, head, hexdump, hostname, hwclock, id, ifconfig,
ifdown, ifup, kill, killall, klogd, ln, logger, logname, logread,
ls, md5sum, mkdir, mkfifo, mknod, mkswap, mktemp, more, mv, nc,
netstat, nslookup, od, pidof, ping, ping6, pivot_root, printf,
ps, pwd, readlink, renice, reset, rm, rmdir, route, run-parts,
sed, seq, sh, sleep, sort, start-stop-daemon, strings, stty, sync,
sysctl, syslogd, tail, tar, tee, telnet, test, tftp, time, top,
touch, tr, traceroute, true, tty, udhcpc, uname, uniq, unzip,
uptime, vi, watch, wc, wget, which, who, whoami, yes, zcat

In plain English:

Multi-call binary means its a single program combining the functions of a large number of utilities. When you first install openslug it will have links for each function so you can use the functions as you would normally but it is important to realise that you are getting a cut-down or "light" version of the function.

For example lets consider the gzip compression tool:

root@zebidee:~# gzip -h
gzip: invalid option -- h
BusyBox v1.01 (2006.06.09-14:27+0000) multi-call binary

Usage: gzip [OPTION]... [FILE]...

Compress FILE(s) with maximum compression.
When FILE is '-' or unspecified, reads standard input. Implies -c.

Options:
-c Write output to standard output instead of FILE.gz
-d Decompress
-f Force write when destination is a terminal

root@zebidee:~# ipkg install gzip
Installing gzip (1.3.5-r1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/slugos-bag/cross/3.10-beta/gzip_1.3.5-r1_armeb.ipk
Configuring gzip
update-alternatives: Linking //bin/gunzip to gunzip.gzip
update-alternatives: Linking //bin/gzip to gzip.gzip
update-alternatives: Linking //bin/zcat to zcat.gzip
root@zebidee:~# gzip -h
gzip 1.3.5
(2002-09-30)
usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
-c --stdout write on standard output, keep original files unchanged
-d --decompress decompress
-f --force force overwrite of output file and compress links
-h --help give this help
-l --list list compressed file contents
-L --license display software license
-n --no-name do not save or restore the original name and time stamp
-N --name save or restore the original name and time stamp
-q --quiet suppress all warnings
-r --recursive operate recursively on directories
-S .suf --suffix .suf use suffix .suf on compressed files
-t --test test compressed file integrity
-v --verbose verbose mode
-V --version display version number
-1 --fast compress faster
-9 --best compress better
file... files to (de)compress. If none given, use standard input.
Report bugs to <bug-gzip@gnu.org>.
root@zebidee:~# ipkg remove gzip
Removing package gzip from root...
update-alternatives: Linking //bin/gunzip to busybox
update-alternatives: Linking //bin/gzip to busybox
update-alternatives: Linking //bin/zcat to busybox

As you can see, the full version of gzip supports far more options than the busybox gzip, however the busybox version will be sufficient for most simple tasks. You are most likely to see problems when trying to run scripts intended for a full Linux install, in which case you have three options:

  1. Install the relevant program
  2. Find a simpler version of the script
  3. Hack the script to remove the option
  4. Adapt another program's script (generic init.d scripts only)

Although I've done it on occasions I don't recommend option 3. Don't try 4 unless you're certain the two programs launch and reload the same way. Usually 1 is the quickest safe option. Finding alternative scripts is tricky as many scripts available on the net are intended for PC-based servers and they can be huge and very complex.

An example of a command with missing options is "start-stop-daemon". Scripts often use the -o/--oknodo option when stopping a process to instruct it not to return an error if the process is already ended or the -R/--retry option to indicate that it should keep on trying to end processes for a time. The busybox version does not support these options.