linux系统启动流程

linux系统启动流程:

      1.按下电源按钮 power  on

      2.进行自检(比如硬件设备:硬盘,网卡等),执行BIOS并初始化设备,也会进行自检,并会查找启动介质(如:CD-ROM,FD,USB,HDD),这里以HDD为启动介质。

       3.MBR(主引导记录,001):Bootloader,partition table,magic nimber。GRUB中的stage1就属于bootloader中,其中所含的驱动少。

        4.stage1再加载stage2(stage1.5是个桥梁),在stage2中有驱动,能认识分区里的东西,文件系统,/boot,之后就可读取grub.conf

   [root@station22 ~]# cat /boot/grub/grub.conf
 

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda3
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0     #默认从第一个菜单启动
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.32-279.el6.i686)
 root (hd0,0)     #操作系统内核和引导文件所在的磁盘分区,表示第一块硬盘的第一个分区
 kernel /vmlinuz-2.6.32-279.el6.i686 ro root=UUID=678a08e0-6141-44d3-8274-d800bdef37b4 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet       #系统内核及boot命令用到的参数
 initrd /initramfs-2.6.32-279.el6.i686.img    #系统引导程序
 

        5.加载kernel和imag映像文件(包含有bin,init,lib,sys等)

         6.启动第一个进程:init。  

                         init的工作是根据/etc/inittab来执行相应脚本,进行系统初始化,如设置键盘、字体、装在模块、设置网络等。

        [root@station22 ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
 

      7.由init启动的进程都保存在目录/etc/rc.d/rc?中,其中?代表运行级别,运行下面的程序。

在/etc/rc.d/rc.?d中的内容都是些符号链接文件,/etc/rc.d/rc.sysinit是由init执行的第一个脚本,初始化环境。

[root@station22 rc1.d]# ll
总用量 0
lrwxrwxrwx. 1 root root 20 4月  11 11:16 K01certmonger -> ../init.d/certmonger
lrwxrwxrwx. 1 root root 24 4月  25 21:20 K01libvirt-guests -> ../init.d/libvirt-guests
lrwxrwxrwx. 1 root root 21 4月  25 21:21 K01libvirt-qmf -> ../init.d/libvirt-qmf
 

lrwxrwxrwx. 1 root root 18 4月  11 11:22 S13cpuspeed -> ../init.d/cpuspeed
 

 

S开头代表start,默认开机要执行的服务。K代表kill,数字表示执行顺序,越小越先执行。

再加载六个控制台以进入登录界面,以及一些其他的文件等。

           8.启动完成。

(这是本人的第一篇博客,在linux这方面还有很多的欠缺,希望各位前辈们能够多加指导下)

 

 

  

本文出自 “晴子” 博客,转载请与作者联系!

你可能感兴趣的:(linux启动)