BusyBox: A Swiss Army Knife for Linux
BusyBox is most useful on a system without a set of regular Linux utility programs, but you'll probably be exploring it on a standard Linux system. Because of this, you should use the PREFIX variable when installing BusyBox. The installation process creates symbolic links for all the utilities that BusyBox supports. This allows you to enter ls instead of busybox ls. Suppose you had begun working with BusyBox in the /tmp directory (such that a directory called /tmp/busybox-0.45 was created by the tar command). Then, if you want to create symbolic links in the same area, use this command:
make PREFIX=/tmp/busybox-0.45 install
The /tmp/busybox-0.45 directory will then contain subdirectories named bin, sbin and usr, each with symbolic links to /bin/busybox. You'll also need to copy the busybox binary to /bin before using these symbolic links:
cp /tmp/busybox-0.45/busybox /binNow you're ready to explore the symbolic links in your BusyBox subdirectories. For example, change to the bin directory:
cd /tmp/busybox-0.45/binThen use the ls symbolic link with the --help option:
./ls --helpYou see the same help text as indicated previously. This shows you that BusyBox is being used instead of the standard ls command on your Linux system.
BusyBox uses the GNU C library, or glibc, which can add substantially to the space requirements of an embedded system or boot disk. You might consider looking at alternate C libraries to save space. Examples include minix libc and newlibc. Another example that looks promising but doesn't yet support the full functionality of BusyBox is the uC-libc project from Rt-Control (see http://www.uclinux.org/). The maintainer of BusyBox, Erik Andersen, is currently working to enhance this mini C library so that it can be used to reduce the total size requirements for BusyBox.
The description of BusyBox so far is straightforward, but doesn't capture all that the program offers. Returning to the source code you un-tarred when you compiled BusyBox, load the file busybox.def.h into a text editor:
cd /tmp/busybox-0.45 vi busybox.def.h
The first part of this file (about the first 100 lines) contains #define statements for each utility capability that will be included in BusyBox. If you don't want to include the capabilities of one of these utilities, simply comment out that line. For example, if you don't need sed in the system you are using BusyBox on, comment out the line for sed using two forward slashes, like this:
//#define BB_SEDCommenting out a few of the larger utilities greatly reduces the size of the final busybox binary. For example, removing five complex programs (init, tar, sfdisk, gzip and gunzip) reduces the size of the busybox binary from 260KB to 155KB.
The second part of the busybox.def.h file (after a few explanatory comments) contains #define statements that activate or disable various features of BusyBox. Some of these features are intended to save memory, such as eliminating the use of the /proc file system, reducing the amount of on-line help provided and eliminating the use of regular expressions. Other #defines are specific to features of a single command. For example, you can eliminate the ability to create new tar files with the tar features of BusyBox. Unless you really need to shave off a couple more KB in the size of BusyBox, you shouldn't need to alter the #define options in the second section of the busybox.def.h file.
Embedded versions of Linux such as Lineo's Embedix may be the most obvious use of BusyBox, but you might come up with many other uses. For example, if you need to create an initrd file to boot up a system with unusual hardware, you can use BusyBox functionality to add the basic system utilities with a single easy-to-manage binary. Or, you might use BusyBox as part of a boot diskette or single-disk version of Linux, as the Linux Router Project and the Debian boot floppies.
- Great Scott! It's Version 13!
- Numerical Python
- Divx# Watch The Other Woman Full HD Online Streaming Viooz
- NSA: Linux Journal is an "extremist forum" and its readers get flagged for extra surveillance
- Tech Tip: Really Simple HTTP Server with Python
- Adminer—Better Than Awesome!
- RSS Feeds
- It Actually Is Rocket Science
- Linux Systems Administrator
- Senior Perl Developer