BusyBox裁剪
简介:
BusyBox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以及telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀。简单的说BusyBox就好像是个大工具箱,它集成压缩了 Linux 的许多工具和命令,也包含了 Linux 系统的自带的shell。
注:大部分平台都会在发布的sdk包中附带了BuysBox,我们可以使用平台附带的BusyBox,也可以自己裁减编译BusyBox,再替换到平台中的BusyBox
手动裁剪步骤:
1. Busybox 下载:
开源链接:https://busybox.net/downloads/
2. 编译Busybox
(1)设置编译工具链:
declare -x ARCH="arm"
declare -x CROSS_COMPILE="arm-linux-gnueabihf-"
(2)make menuconfig,根据需要对Busybox进行裁剪
1) 不可以裁剪的选项
Busybox Settings -->
Init Utilities -->
Shells -->
Coreutiles -->
2) 可裁剪的选项:
除(1)中的选项外都可以裁剪,Coreutiles -->中看情况裁剪,留下必须的shell命令如ls。
3.make clean
ubuntu@ubuntu:/tmp/busybox/busybox-1.23.2$ make clean
CLEAN .kernelrelease
4.make
ubuntu@ubuntu:/tmp/busybox/busybox-1.23.2$ make
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/split-include
....
5.make install
ubuntu@ubuntu:/tmp/busybox/busybox-1.23.2$ make install
./_install//bin/ash -> busybox
./_install//bin/base64 -> busybox
./_install//bin/cat -> busybox
.....
--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------
6.等待第5步结束后./install目录下就是我们需要的busybox包
ubuntu@ubuntu:/tmp/busybox/busybox-1.23.2/_install$ ls
bin linuxrc sbin usr