Busybox编译安装

Busybox

1 Busybox介绍

在这里插入图片描述
Busybox 最初是由 Bruce Perens 在 1996 年为 Debian GNU/Linux 安装盘编写的。其目标是在一张软盘(存储空间只有1MB多)上创建一个GNU/Linux 系统,可以用作安装盘和急救盘

Busybox 是一个开源项目,遵循GPL v2协议。Busybox将众多的UNIX命令集合进一个很小的可执行程序中,可以用来替代GNU fileutils、shellutils 等工具集。Busybox中各种命令与相应的GNU工具相比,所能提供的选项比较少,但是也足够一般的应用了。Busybox主要用于嵌入式系统

Busybox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以及telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀。简单的说BusyBox就好像是个大工具箱,它集成压缩了Linux 的许多工具和命令,也包含了 Android 系统的自带的shell

定制小型的Linux操作系统:linux内核+busybox

官方网站:https://busybox.net/

2 Busybox使用

busybox 的编译过程与Linux内核的编译类似

busybox的使用有三种方式:

  • busybox后直接跟命令,如 busybox ls
  • 直接将busybox重命名,如 cp busybox tar
  • 创建符号链接,如 ln -s busybox rm

busybox的安装

以上方法中,第三种方法最方便,但为busybox中每个命令都创建一个软链接,相当费事,busybox提供自动方法:busybox编译成功后,执行make install,则会产生一个_install目录,其中包含了busybox及每个命令的软链接

3 busybox编译安装
[root@centos7 ~]#yum -y install   gcc gcc-c++ glibc glibc-devel make pcre pcredevel openssl openssl-devel systemd-devel zlib-devel glibc-static ncurses-devel

[root@centos7 ~]#wget https://busybox.net/downloads/busybox-1.31.1.tar.bz2

[root@centos7 ~]#tar xvf busybox-1.31.1.tar.bz2 
[root@centos7 ~]#cd busybox-1.31.1/
[root@centos7 busybox-1.31.1]#make menuconfig 
#按下面选择,把busybox编译也静态二进制、不用共享库:Settings -->Build Options -->[*] Build static binary (no shared libs)

[root@centos7 busybox-1.31.1]#make 
#如果出错,执行make clean后,重新执行上面命令
[root@centos7 busybox-1.31.1]#ls 
[root@centos7 busybox-1.31.1]#make install 
[root@centos7 busybox-1.31.1]#pwd
/root/busybox-1.31.1
[root@Centos7 busybox-1.31.1]#ls
applets                 debianutils  loginutils              qemu_multiarch_testing
applets_sh              docs         mailutils               README
arch                    e2fsprogs    Makefile                runit
archival                editors      Makefile.custom         scripts
AUTHORS                 examples     Makefile.flags          selinux
busybox                 findutils    Makefile.help           shell
busybox.links           include      make_single_applets.sh  size_single_applets.sh
busybox_unstripped      init         miscutils               sysklogd
busybox_unstripped.map  _install     modutils                testsuite
busybox_unstripped.out  INSTALL      networking              TODO
Config.in               klibc-utils  NOFORK_NOEXEC.lst       TODO_unicode
configs                 libbb        NOFORK_NOEXEC.sh        util-linux
console-tools           libpwdgrp    printutils
coreutils               LICENSE      procps
[root@Centos7 busybox-1.31.1]#ll busybox -h
-rwxr-xr-x 1 root root 2.6M May 14 09:35 busybox

[root@Centos7 busybox-1.31.1]#ls _install/
bin  linuxrc  sbin  usr
[root@Centos7 busybox-1.31.1]#ls _install/bin
arch     cttyhack       fdflush   kbd_mode  mknod       ping           run-parts     tar
ash      date           fgrep     kill      mktemp      ping6          scriptreplay  touch
base64   dd             fsync     link      more        pipe_progress  sed           true
busybox  df             getopt    linux32   mount       printenv       setarch       umount
cat      dmesg          grep      linux64   mountpoint  ps             setpriv       uname
chattr   dnsdomainname  gunzip    ln        mpstat      pwd            setserial     usleep
chgrp    dumpkmap       gzip      login     mt          reformime      sh            vi
chmod    echo           hostname  ls        mv          resume         sleep         watch
chown    ed             hush      lsattr    netstat     rev            stat          zcat
conspy   egrep          ionice    lzop      nice        rm             stty
cp       false          iostat    makemime  nuke        rmdir          su
cpio     fatattr        ipcalc    mkdir     pidof       rpm            sync

[root@Centos7 busybox-1.31.1]#find _install/ -type l |wc -l
396
[root@Centos7 busybox-1.31.1]#du -sh _install/
2.6M	_install/

[root@Centos7 busybox-1.31.1]#mkdir /mnt/sysroot/
[root@Centos7 busybox-1.31.1]#cp -a _install/* /mnt/sysroot/

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值