系统启动和内核管理 --centos5/centos6

1、查看kernel版本:

rpm -qa kernel 

[root@centos6 ~]# rpm -qa kernel 

kernel-2.6.32-696.el6.x86_64

2、linux :kernel +rootfs 

    kernel: 进程管理,内存管理,网络管理,驱动程序,文件系统,安全功能

    rootfs:程序和glibc

    库:

    程序:二进制执行文件

3、内核设计流派:

    单内核:把所有功能集成于同一个程序 vmlinuz-2.6.32-696.el6.x86_64

    微内核:每种功能使用一个单独子系统

4、 linux 内核特点:

    支持模块化:.ko(内核对象)

    如:文件系统,硬件驱动,网络协议

    支持内核模块的动态装载和卸载

[root@centos6 boot]# locate ext4.ko

/lib/modules/2.6.32-696.el6.x86_64/kernel/fs/ext4/ext4.ko

lsmod 加载的模块:

modprobe:

[root@centos6 boot]# lsmod |grep e1000

e1000                 134799  0 


5、 内核核心文件


[root@centos6 boot]# ll -h /boot/vmlinuz-2.6.32-696.el6.x86_64 

-rwxr-xr-x. 1 root root 4.1M Mar 22  2017 /boot/vmlinuz-2.6.32-696.el6.x86_64

centos6/7:辅助的伪跟系统:initramfs-2.6.32-696.el6.x86_64.img 

centos5:initrd-2.6.18-164.el5.img

查看:辅助伪跟系统:

[root@rhel5 ~]# cp /boot/initrd-2.6.18-164.el5.img  /root
[root@rhel5 ~]# mv initrd-2.6.18-164.el5.img initrd-2.6.18-164.el5.img.gz
[root@rhel5 ~]# gzip -d initrd-2.6.18-164.el5.img.gz     
[root@rhel5 ~]# cpio -tv < initrd-2.6.18-164.el5.img 
-rw-------   1 root     root        29016 Nov  2  2010 lib/ohci-hcd.ko
-rw-------   1 root     root        96456 Nov  2  2010 lib/mptbase.ko
-rw-------   1 root     root       146792 Nov  2  2010 lib/ext3.ko


6、模块文件:

[root@rhel5 ~]# ll /lib/modules/2.6.18-164.el5/


7、centos6启动流程:

blob.png


8、post

blob.png



9、rpm -qa grub 

[root@rhel5 ~]# rpm -qa grub

grub-0.97-13.5


10、启动流程:mbr

blob.png



第一个阶段:446字节;

第1.5阶段:

[root@centos6 ~]# locate ext4.ko 

/lib/modules/2.6.32-696.el6.x86_64/kernel/fs/ext4/ext4.ko

第二阶段:/dev/sda1       976M   40M  886M   5% /boot

第二阶段的配置文件:进入grub之后,读取boot 下vmlinuz 内核文件,初始化内核,随后找根目录

blob.png


根目录:

cat /boot/grub/grub.conf 

blob.pngblob.png

根找到了,需要根的文件系统挂载:

blob.png


问题:要挂载根,根的文件系统在哪,在跟下面:

[root@centos6 ~]# locate ext4.ko 

/lib/modules/2.6.32-696.el6.x86_64/kernel/fs/ext4/ext4.ko


解决根的文件系统:

initramfs-2.6.32-696.el6.x86_64.img

[root@centos6 ~]# ls /boot/initramfs-2.6.32-696.el6.x86_64.img  根的文件系统存在initramfs辅助伪根文件系统


[root@centos6 ~]# cpio -tv < initramfs-2.6.32-696.el6.x86_64.img |grep ext4.ko --color  
-rwxr--r--   1 root     root       646648 Jan 25 09:53 lib/modules/2.6.32-696.el6.x86_64/kernel/fs/ext4/ext4.ko


vmlinuz 存在系统光盘上:

[root@centos6 isolinux]# ll /boot/initramfs-2.6.32-696.el6.x86_64.img  vmlinuz 
-rw-------. 1 root root 26663543 Jan 25 09:54 /boot/initramfs-2.6.32-696.el6.x86_64.img
-r-xr-xr-x. 4 root root  4274992 Mar 29  2017 vmlinuz


虚拟文件系统:initramfs-2.6.32-696.el6.x86_64.img 

丢失创建initramfs: 

mkinitrd /boot/initramfs-`uname -r`.imag `uname -r`

实验:1、[root@centos6 boot]# rm -f initramfs-2.6.32-696.el6.x86_64.img 

实验:2、rm -f  vmlinuz-2.6.32-696.el6.x86_64

1、光盘引导:ecs按键

2、cd-rom drive 

blob.png

3、进入救援模式:

blob.png

4、英文

blob.png

5、不需要设置网络

blob.png


6、

blob.png

7、

blob.png

8、

blob.png

9、chroot /mnt/sysimage ;mkinitrd initramfs-`uname -r`.img `uname -r` ;sync;sync;

blob.png

10、mount /dev/sr0 /mnt; cp vmlinuz /boot/vmlinuz-`uname -r`

blob.png

11、

exit

exit

reboot 



猜你喜欢

转载自blog.51cto.com/13718453/2469885