mini linux
-
启动流程:
POST自检—>BootSequence(BIOS)-->BootLoader-->Kernel(ramdisk)-->rootfs根文件系统—>/sbin/init(centos7变成systemd)
bootloader:lilo;grub legacy;grub2(stage1:mbr;stage1_5:filesystem driver;state2)
编写服务脚本 upstart配置文件(centos7变成systemd unit文件)
centos6
/etc/init/*.conf
/etc/inittab
默认运行级别;运行系统初始化脚本:/etc/rc.d/rc.sysinit;/etc/rc.d/rc $runlevel;启动终端,并运行login;启动图形终端
-
内核编译:
make menuconfig --> .config
make [-j #]
make modules_install
make install
-
mini linux步骤:
bootloader: grub
内核:kernel (非模块方式)
根文件系统:busybox二进制
复制程序及其依赖的库文件脚本:
#!/bin/bash
#
target=/mnt/sysroot
[ -d $target ] || mkdir /mnt/sysroot
read -p "A command: " command
libcp() {
for lib in $(ldd $1 | grep -o "[^[:space:]]*/lib[^[:space:]]*"); do
libdir=$(dirname $lib)
[ -d $target$libdir ] || mkdir -p $target$libdir
[ -f $target$lib ] || cp $lib $target$lib
done
}
while [ "$command" != ‘quit‘ ]; do
if ! which $command &> /dev/null; then
read -p "No such command, enter again: " command
continue
fi
command=$(which --skip-alias $command)
cmnddir=$(dirname $command)
[ -d $target$cmnddir ] || mkdir -p $target$cmnddir
[ -f $target$command ] || cp $command $target$command
libcp $command
read -p "Another command(quit): " command
done
kernel+busybox:
静态方式编译,依赖于glibc-static;
# cd /usr/src/linux
# make M=drivers/net/ethernet/intel/e1000/
# make M=path/to/somedir/