Mini Linux:
启动流程:
CentOS 6:
POST --> BootSequence(BIOS) --> BootLoader --> Kernel (ramdisk) --> rootfs --> /sbin/init
编写服务脚本
upstart配置文件
/etc/init/*.conf(centos6) /etc/inittab(centos5)
默认运行级别
运行系统初始化脚本:/etc/rc.d/rc.sysinit
/etc/rc.d/rc $runlevel
启动终端,并运行login
启动图形终端
bootloader分类
lilo
grub legacy
grub2
stage1: mbr
stage1_5: filesystem driver
state2:
CentOS 7:
POST --> BootSequence(BIOS) --> BootLoader --> Kernel (ramdisk) --> rootfs --> /sbin/systemd
编写服务脚本
systemd unit文件
内核编译:
make menuconfig --> .config
make [-j #]
make modules_install
make install
编译步骤:
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
Mini Linux: kernel+busybox
busybox:
静态方式编译,依赖于glibc-static;
编译单个内核模块:
# cd /usr/src/linux
# make M=drivers/net/ethernet/intel/e1000/
# make M=path/to/somedir/
rsyslog:
日志:历史日志
历史事件:
时间,事件
日志级别:事件的关键性程度,Loglevel
系统日志服务:
syslog:
syslogd: system
klogd: kernel
rsyslog:
syslogd
klogd
rsyslog:
多线程;
UDP, TCP, SSL, TLS, RELP;
MySQL, PGSQL, Oralce实现日志存储;
强大的过滤器,可实现过滤日志信息中任何部分;
自定义输出格式
原文地址:https://www.cnblogs.com/hanshanxiaoheshang/p/9281268.html