Android Installing Busybox Command Line Tools

Introduction (Prebuilt binary)
This article describes how to install the busybox command line tools in the Android file-system. Please note that a pre-built version of busybox has been attached to this article if you would prefer not to build busybox yourself. Skip to Installing Busybox to filesystem if you select to use the prebuilt version. For the more information on the latest busybox environment visit: www.busybox.net


 * [[Media:Busybox.tar.gz|Pre-built Busybox 1.19.3]]

Configure and Build
Download busybox-1.19.3.tar.bz2 from www.busybox.net.

Extract the busybox source pc$ tar jxf busybox-1.19.3.tar.bz2 pc$ cd busybox-1.19.3/

Or if you prefer, you can get the latest version of busybox pc$ git clone git://busybox.net/busybox.git pc$ cd busybox/ pc$ git checkout -b my_working_branch 1_19_3

Export path to where the cross-compiler is located on the host. For more information on setting up cross-compiler in environment visit: Cross Compilers pc$ export PATH=$PATH://bin/

Configure busybox pc$ make menuconfig

In menuconfig set the following options Busybox Settings --> Build Options --> Build Busybox as a static binary (no shared libs) -  Enable this option by pressing "Y" Busybox Settings --> Build Options --> Cross compiler prefix -  Set this option equal to "arm-none-linux-gnueabi-" Busybox Settings --> General Configuration --> Don't use /usr -  Enable this option by pressing "Y" Linux Module Utilities --> [ ] Simplified modutils [*]  insmod [*]  rmmod [*]  lsmod [*]    Pretty output [ ]  modprobe [ ]  depmod Linux Module Utilities --> [ ] Support version 2.2/2.4 Linux kernels Linux Module Utilities --> [ ] Try to load module from a mmap'ed area Linux Module Utilities --> [*] Support tainted module checking with new kernels Linux Module Utilities --> Default directory containing modules - Set this option to nothing Linux Module Utilities --> Default name of modules.dep - Set this option to nothing

You can also enable and disable at that time the tools that are needed/not needed. Example of tools that could be disabled: Print Utilities, Mail Utilities

Build busybox pc$ make

Copying Busybox to filesystem
Once the busybox executable has been placed in the target file system you will need to "install" busybox, i.e. you will need write permission. Therefore it's recommended to place busybox in the system partition where you can use the "adb remount" command to get write permissions.

Create a busybox directory in the target file-system. For example: pc$ mkdir -p $MYDROID/out/target/product/blaze/system/busybox

Copy the busybox binary to the /bin directory in the target file-system: pc$ install -m 777 busybox $MYDROID/out/target/product/blaze/system/busybox/busybox

Add the busybox directory to the default path. Open the init.rc file: pc> vim $MYDROID/out/target/product/blaze/root/init.rc Add /system/busybox to PATH in init.rc: export PATH /system/busybox: /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin

Installing Busybox at run-time
Bootup the board with Android filesystem, remount system with read-write permissions pc> ./adb root pc> ./adb remount

Install the busybox command line tools on the target by executing the following commands on booted filesystem:

pc> ./adb shell target$ cd /system/busybox target$ ./busybox --install. target$ ./sh

NOTE: Don't forget the DOT at the end of the "install" step above!

Make the Busybox shell the default shell
Save the original sh executable by renaming it, and then create a soft-link to busybox sh: target$ cd /system/bin target$ mv sh sh.android target$ ln -s /system/busybox/sh sh

Now when you open a shell using "./adb shell" you will have the full busybox capabilities immediately. The serial port shell will also utilize busybox when you power-up the board.