现在的位置: 首页 > 综合 > 正文

busybox构建linux系统

2012年09月12日 ⁄ 综合 ⁄ 共 1052字 ⁄ 字号 评论关闭

我的主要目的是为了debug linux kernel. 完全装一个UBUNTU或其它系统不值。于是就想自己编译一个最小系统。

下载busybox后,做一些基本配置后,就可以make install. 默认生成的_install目录在busybox的根目录下,接下来的动作我已写生脚本,参考如下:

#!/bin/bash

#create directory for linux kernel tree
DIR="proc sys etc dev"
for directory in "$DIR"
do
    if [ ! -d "$directory" ]
    then
    mkdir $directory
    fi
done

#create control char device
cd dev
mknod console c 5 1 
mknod null c 1 3
cd ..
cd etc

#create fstab file
if [ ! -e "fstab" ]
then
    touch fstab
    echo "#device mount-point type options dump fsck">fstab
    echo "proc /proc proc defaults 0 0">>fstab
    echo "sysfs /sys sysfs defaults 0 0">>fstab
fi

#create init script
mkdir init.d
if [ ! -e "init.d/rcS" ]
then
    touch init.d/rcS
    echo "#!/bin/sh">init.d/rcS
    echo "mount -a">>init.d/rcS
fi
chmod +x init.d/rcS

#create inittab
if [ ! -e "inittab" ]
then
    touch inittab
    echo "#/etc/inittab">inittab
    echo "::sysinit:/etc/init.d/rcS">>inittab
    echo "console::respawn:-/bin/sh">>inittab
    echo "::ctrlaltdel:/sbin/reboot">>inittab
    echo "::shutdown:/bin/unmount -a -r">>inittab
fi

#check if we are in _install directory
cd ..
if [ -e "linuxrc" ]
then
    rm linuxrc
fi
ln -sv bin/busybox init
find . | cpio --quiet -H newc -o | gzip -9 -n > ./initrd.gz

 

接下来的工作就是要虚拟机中进行模拟测试了,太晚上,已经凌晨1:00了,明天再补充。

抱歉!评论已关闭.