玩转开发板--最简单的根文件系统树的制作-3

安装busybox

    Linux系统在执行一条命令时,默认会到/bin、/sbin、/usr/bin、/usr/sbin这些路径下找,如果找不到则提示command not found,当然我们也可以通过PATH环境变量告诉系统其他命令存放的路径,现在根文件系统树下这些路径并没有Linux系统相关命令,这时我们就需要下载命令来满足我们的需求: BusyBox是一个集成了一百多个常用Linux命令和工具的软件,如ls、cat、ifconfig、vim、grep等有些人将BusyBox称为Linux的瑞士军刀,简单的说BusyBox是个大工具箱,它集成压缩了Linux的许多工具和命令。我们通过下载busybox源码、配置编译并安装它就会提供这些Linux的基本命令的实现,它们将会被安装到根文件系统树的bin、sbin、usr/bin、usr/sbin等路径下。

    [guozhihao@localhost rootfs]$ cd ~/gitee/fl2440/linux/rootfs/

    [guozhihao@localhost rootfs]$ ls

    apps  data  etc   lib  proc  sbin  tmp  var

    bin   dev   info  mnt  root  sys   usr

    [guozhihao@localhost rootfs]$ mkdir 3rdparty    //用来存放第三方软件

    [guozhihao@localhost rootfs]$ cd 3rdparty/

    [guozhihao@localhost 3rdparty]$ wget https://busybox.net/downloads/busybox-1.27.2.tar.bz2

    本此操作是使用1.27.2版本

    [guozhihao@localhost 3rdparty]$ tar -xjf busybox-1.27.2.tar.bz2    //解压

    [guozhihao@localhost 3rdparty]$ cd busybox-1.27.2

    [guozhihao@localhost busybox-1.27.2]$ ls

     applets        include                 networking

    applets_sh     init                    printutils

    arch           INSTALL                 procps

    archival       libbb                   qemu_multiarch_testing

    AUTHORS        libpwdgrp               README

    Config.in      LICENSE                 runit

    configs        loginutils              scripts

    console-tools  mailutils               selinux

    coreutils      Makefile                shell

    debianutils    Makefile.custom         sysklogd

    docs           Makefile.flags          testsuite

    e2fsprogs      Makefile.help           TODO

    editors        make_single_applets.sh  TODO_unicode

    examples       miscutils               util-linux

    findutils      modutils

    [guozhihao@localhost busybox-1.27.2]$ export TERM=vt100

    [guozhihao@localhost busybox-1.27.2]$ make menuconfig    //以菜单方式打开最好全屏打开

   

    进入busybox Settings-->填写自己所属的交叉编译器位置、以及指定busybox安装你编辑的rootfs文件夹位置

    

    

    进入Linux System Utilities-->取消勾选nsenter(可能在编译过程出现错误)

    

    进入Coreutils-->取消勾选Enable -d and -f flags选项

    

 

    编译并安装busybox到根文件系统树下路径下:

    [guozhihao@localhost busybox-1.27.2]$ make && make install

    

    切换到根文件系统树路径下,创建符号链接指向busybox程序,如果使用initramfs根文件系统启动需要命令:

    [guozhihao@localhost busybox-1.27.2]$ cd ../../linux/rootfs/

    [guozhihao@localhost rootfs]$ ln -s bin/busybox init

 

    列出根文件系统目录树下的linux命令,这些命令其实都是符号链接到busybox:

    [guozhihao@localhost busybox-1.27.2]$ ls ../../linux/rootfs/

    apps  data  etc   init  linuxrc  proc  sbin  tmp  var
    bin   dev   info  lib   mnt      root  sys   usr

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值