mini linux:linux
启动流程:ios
centos6:post》bootsequence(bios)》BootLoader(mbr)》kernel(如没法直接识别硬盘驱动,需借助ramdisk)》rootfs》/sbin/initvim
centos7:post》bootsequence(bios)》BootLoader(mbr)》kernel(如没法直接识别硬盘驱动,需借助ramfs)》rootfs》/sbin/systemdcentos
bootloader:lilo、grub legacy、grub2bash
stage1:mbr网络
stage1_5:filesystem driver架构
stage2:grub程序自己app
内核编译步骤:ide
一、make menuconfig》生成.config文件post
二、make [-j #]
三、make modules_install
四、make install
mini linux步骤:
一、内核:kernel(非模块方式)
二、根文件系统:busybox
三、按需进行命令移植
复制程序及其依赖的库文件脚本示例:
#!/bin/bash
#
target=/mnt/sysroot
[ -d $target ] || mkdir $target
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 "a other command(quit):" command
done
根据cpu、pci、ethernet、filesystem等设备信息挑选内核参数,lscpu、lspci、lsusb等
编译时选择的基本模块与功能介绍
1.[*] 64-bit kernel #编译64位内核
2.Enable loadable module suppose #支持内核的装载与卸载 [*] module unloding
3.Bus options #相关PCI接口支持
4.Processor type and features #关于处理器版本选择,选择本身处理器合适的
5.Device drivers #关于硬盘,网卡各设备的驱动lspci查看系统设备信息(本身选择)
6.File Systems #文件系统支持(本身选择)
7.Excutable file formates/Emulattions #支持文件可执行文件的格式(本身选择)
8.Networking Support #网络服务支持
准备硬盘,安装grub,分区,复制编译后的内核
default=0
timeout=3
title minilinux
root (hd0,0)
kernel /bzImage ro root=/dev/sda2
编译安装单文件的busybox,静态方式编辑依赖glibc-static
选择
[*] Build static binary (no shared libs) 静态编译
What kind of applet links to install (as soft-links) ---> (X) as soft-links
(./_install) Destination path for 'make install' 定义安装路径
default=0timeout=3title minilinuxroot (hd0,0)kernel /bzImage ro root=/dev/sda2 init=/sbin/init