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.
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
|Pandas||Aug 17, 2016|
|Juniper Systems' Geode||Aug 16, 2016|
|Analyzing Data||Aug 15, 2016|
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- NVMe over Fabrics Support Coming to the Linux 4.8 Kernel
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- New Version of GParted
- All about printf
- Analyzing Data
- Tor 0.2.8.6 Is Released
- Blender for Visual Effects
- Juniper Systems' Geode
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide