busybox 裁剪参考


1. 制作工具

1.1 Busybox下载与解压

本章节以busybox-1.20.2版本为例说明

执行以下命令下载与解压busybox-1.20.2.tar.bz2:

wget https://busybox.net/downloads/busybox-1.20.2.tar.bz2

tar -xvf busybox-1.20.2.tar.bz2

cd busybox-1.20.2

我们需要对busybox-1.20.2合入附件busybox_SS.patch

下载 busybox_SS.patch ,将其放入busybox-1.20.2文件夹下,执行以下命令:

patch -p1 < busybox_SS.patch

Busybox源码下载地址:https://busybox.net/downloads/


1.2 配置环境

编译环境配置请根据:编译环境搭建章节的2.1环境变量配置选择合适的编译环境。


1.3 编译busybox

接下来以64位为例,进行busybox编译修改的演示,如选择32位,则对sstar_alkaid_arm-aarch64-linux-gnu-glibc_defconfig 文件进行修改,其中 CONFIG_CROSS_COMPILER_PREFIX 请根据根据1.2实际配置

make sstar_alkaid_arm-aarch64-linux-gnu-glibc_defconfig

make install

在_install/ 生成如下文件

cd _install/

tar -czf busybox-1.20.2-aarch64-linux-gnu-glibc-10.2.1-dynamic.tar.gz *

此处要生成的文件名应该根据busybox将在什么平台环境下运行而决定

通过project/configs/demo/defconfigs下对应的deconfig看到:

拷贝busybox-1.20.2-aarch64-linux-gnu-glibc-10.2.1-dynamic.tar.gz 到 project/image/busybox/

make image-fast 重新生成image 烧录


2. busybox 裁剪参考

2.1 根据busybox 主选项进行分类

配置选项 占用空间 功能描述
CONFIG_DESKTOP 8K 开启一些非必要的配置以兼容桌面系统
CONFIG_FEATURE_NON_POSIX_CP \ Non-POSIX标准cp命令
CONFIG_FEATURE_PIDFILE \ pid文件生成路径
CONFIG_FEATURE_SUID \ 开启root权限管理
CONFIG_FEATURE_UTMP \ 用于记录当前登录用户, who功能会使用到
CONFIG_FLOAT_DURATION \ 使applets支持浮点, 例如:sleep N.NNN
CONFIG_INCLUDE_SUSv2 \ 开启UNIX 98支持
CONFIG_SHOW_USAGE 7K applets 帮助信息
CONFIG_STACK_OPTIMIZATION_386 \ i386架构stack-boundary=2

2.2 按照 Applets 显示顺序进行排序

下列为busybox工具的支持配置, 可以根据需要选择是否开启

选项名称 模块描述
Archival Utilities 各类压缩格式以及压缩工具的配置
Coreutils 系统常用工具的配置
Console Utilities 控制台工具配置
Debian Utilities Debian 系统工具
klibc-utils klibc 工具,包括minips(ps), nuke(rm -rf) , resume, run-init
Editors 编辑工具, 包括sed, awk, vi等
Finding Utilities find, grep, xargs 等工具功能的配置
Init Utilities 系统初始化工具, 包括reboot, poweroff,halt等
Login/Password Management Utilities 登录以及密码管理工具
nux Ext2 FS Progs Ext2 文件系统管理相关工具
Linux Module Utilities linux 模块管理, insmod/rmmod/modprobe等
Linux System Utilities linux 系统管理工具
Miscellaneous Utilities 杂项类工具
Networking Utilities 网络管理工具, 可配置Ipv4/ipv6支持,以及tftp, telnetd等工具的支持
Print Utilities 打印机工具,包括lpd/lpr/lpq 工具
Mail Utilities 邮件相关工具
Process Utilities 进程管理工具, 包括free, kill, top, watch等
Runit Utilities runit 套件的支持
Shells 包括ash, 以及hush两种shell的支持
System Logging Utilities 系统log工具的支持