• 简单搭建内核调试环境--4 fsroot


    跳转到目录 点这里 
    cd /kernel-debug wget https://busybox.net/downloads/busybox-1.3.0.tar.bz2 tar -zvxf busybox-1.32.0.tar.gz cd busybox-1.32.0
    跳转到目录 点这里 

    编译和安装busybox
    make ARCH=x86_64 menuconfig
     Settings  --->  Build Options -[ ] Build static binary (no shared libs) (NEW) 
    make ARCH=x86_64
    make install 
    创建根文件目录 fsroot
    mkdir -p /kernel-debug/fsroot/
    写一个脚本来人创建必要的目录
    install.sh
    mkdir -p /kernel-debug/fsroot/lib
    mkdir -p /kernel-debug/fsroot/mnt
    mkdir -p /kernel-debug/fsroot/home
    mkdir -p /kernel-debug/fsroot/proc
    mkdir -p /kernel-debug/fsroot/root
    mkdir -p /kernel-debug/fsroot/sys
    mkdir -p /kernel-debug/fsroot/tmp
    mkdir -p /kernel-debug/fsroot/dev
    mkdir -p /kernel-debug/fsroot/var/lock
    mkdir -p /kernel-debug/fsroot/var/log
    mkdir -p /kernel-debug/fsroot/var/run
    mkdir -p /kernel-debug/fsroot/var/tmp
    mkdir -p /kernel-debug/fsroot/etc/init.d/
    touch /kernel-debug/fsroot/etc/inittab
    touch /kernel-debug/fsroot/etc/init.d/rcS
    touch /kernel-debug/fsroot/etc/fstab
    touch /kernel-debug/fsroot/etc/profile
    touch /kernel-debug/fsroot/etc/init.d/ifconfig-all
    chmod 755 /kernel-debug/fsroot/etc/inittab
    chmod 755 /kernel-debug/fsroot/etc/init.d/rcS
    chmod 755 /kernel-debug/fsroot/etc/fstab
    chmod 755 /kernel-debug/fsroot/etc/profile
    chmod 755 /kernel-debug/fsroot/etc/init.d/ifconfig-all
    sh install.sh
    [hun-hh fsroot]# sh /kernel-debug/fsroot/install.sh
    看一下目录结构
    [hun-hh fsroot]# tree 
    ├── dev
    ├── etc
    │   ├── eth0-setting
    │   ├── eth1-setting
    │   ├── fstab
    │   ├── init.d
    │   │   ├── ifconfig-all
    │   │   ├── ifconfig-eth0
    │   │   ├── ifconfig-eth1
    │   │   └── rcS
    │   ├── inittab
    │   └── profile
    ├── home
    ├── install.sh
    ├── lib
    ├── mnt
    ├── proc
    ├── root
    ├── sys
    ├── tmp
    └── var
        ├── lock
        ├── log
        ├── run
        └── tmp
    复制到  busybox 到自己根文件目录
    cp -a /kernel-debug/busybox-1.32.0/_install/* /kernel-debug/fsroot

    配置一些基本的配置文件

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/inittab

    #this is run first except when booting in single-user mode.
    ::sysinit:/etc/init.d/rcS
    # /bin/sh invocations on selected ttys
    ::respawn:-/bin/sh
    # Start an "askfirst" shell on the console (whatever that may be)
    ::askfirst:-/bin/sh
    # Stuff to do when restarting the init process
    ::restart:/sbin/init
    # Stuff to do before rebooting
    ::ctrlaltdel:/sbin/reboot
    ::shutdown:/sbin/swapoff -a

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/init.d/rcS

    #!/bin/sh
    #This is the first script called by init process
    /bin/mount -a
    echo /sbin/mdev>/proc/sys/kernel/hotplug
    mdev -s

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/fstab

    #device     mount-point     type         options       dump     fsck order
    proc        /proc           proc         defaults        0        0
    tmpfs       /tmp            tmpfs       defaults        0        0
    sysfs       /sys            sysfs        defaults        0        0
    tmpfs       /dev            tmpfs        defaults        0        0

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/profile

    #!/bin/sh
    export HOSTNAME=farsight
    export USER=root
    export HOME=root
    export PS1="[$USER@$HOSTNAME W]# "
    #export PS1="[[33[01;32m]$USER@[33[00m][33[01;34m]$HOSTNAME[33[00m W]$ "
    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH
    export PATH LD_LIBRARY_PATH
    ./bin/sh /etc/init.d/ifconfig-all

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/eth0-setting

    IP=192.168.100.103
    Mask=255.255.255.0
    Gateway=192.168.100.1
    DNS=8.8.8.8
    MAC=00:0C:29:EE:66:18

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/eth1-setting

    IP=192.168.43.230
    Mask=255.255.255.0
    Gateway=192.168.43.1
    DNS=8.8.8.8
    MAC=00:0c:29:ee:66:22

    [hun-hh fsroot]# vi /kernel-debug/fsroot/etc/init.d/ifconfig-all

    #!/bin/sh
    if [ -f /etc/eth0-setting ] ; then
    source /etc/eth0-setting
    ifconfig eth1 down
    ifconfig eth1 hw ether $MAC
    ifconfig eth1 $IP netmask $Mask up
    route add default gw $Gateway
    fi
    if [ -f /etc/eth1-setting ] ; then
    source /etc/eth1-setting
    ifconfig eth1 down
    ifconfig eth1 hw ether $MAC
    ifconfig eth1 $IP netmask $Mask up
    route add default gw $Gateway
    fi
    echo Done > /dev/ttySAC2 
  • 相关阅读:
    函数
    特殊集合
    集合
    数组复习
    数组
    IPython--转
    python 单例模式总结
    拼多多笔试题
    python 创建实例--待完善
    转--算法时间复杂度
  • 原文地址:https://www.cnblogs.com/heling/p/14159112.html
Copyright © 2020-2023  润新知