Linux 开机启动过程

Linux系统最终呈现给用户的,要么是一个命令行界面,也可能是一个图形化界面。不管是哪种呈现,能看到说明服务器已经装载系统成功了。 对于很多用户来说,学习、使用Linux,可能就起始于系统已经装载成功的界面。

总体来说,Linux启动以 init 或 systemd 进程的启动为标志,分为两个过程:1.系统引导过程 2.脚本初始化过程

详细的流程图,如下:
这里写图片描述

以下,开始一个大概的说明:

  1. BIOS阶段

第一步,硬件自检(Power-on Self Test);通过后,BIOS程序会被加载到内存。
然后,BIOS会按照启动顺序去查找磁盘头的MBR信息,并加载、执行MBR中的Bootloader程序。

  1. BootLoad阶段,以grub为例:

Briefly, boot loader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software (such as the Hurd or the Linux). The kernel, in turn, initializes the rest of the operating system (e.g. GNU).

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn.

GRUB,多系统启动程序,其执行过程可分为三个步骤:
  Stage1:它的主要工作就是查找并加载第二段Bootloader程序(stage2),MBR根本找不到文件系统,也就找不到stage2所存放的位置,因此,就有了stage1_5
  Stage1_5:该步骤就是为了识别文件系统
  Stage2:GRUB程序会根据/boot/grub/grub.conf文件查找Kernel的信息,然后开始加载Kernel程序,当Kernel程序被检测并在加载到内存中,GRUB就将控制权交接给了Kernel程序。/boot/grub/grub.conf文件,该配置文件的信息如下:

 #boot=/dev/sda
 default=0 #设定默认启动的title的编号,从0开始
   timeout=5 #等待用户选择的超时时间
   splashimage=(hd0,0)/boot/grub/splash.xpm.gz #GRUB的背景图片
   hiddenmenu #隐藏菜单
   title CentOS (2.6.18-194.el5PAE) #内核标题
       root (hd0,0) #内核文件所在的设备
       kernel /vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/ #内核文件路径以及传递给内核的参数
       initrd /initrd-2.6.18-194.el5PAE.img #ramdisk文件路径

附:查看内核版本及大小,

du -h /boot/vmlinuz-`uname -a |awk '{print $3}'`

4.0M    /boot/vmlinuz-2.6.32-431.el6.x86_64

猜你喜欢

转载自blog.csdn.net/qq_15742255/article/details/80903418