Linux 学习笔记(8)

八、 启动引导
1 Linux 的启动流程

  1. BIOS 自检
  2. 启动 GRUB/LILO
  3. 运行 Linux kernel 并检测硬件
  4. 挂载根文件系统
  5. 运行 Linux 系统的第一个进程 init( 其 PID 永远为 1 ,是所有其它进程的父进程 )
  6. init 读取系统引导配置文件 /etc/inittab 中的信息进行初始化 7) 执行系统初始化脚本- /etc/rc.d/rc.sysinit ,执行系统初始化 ( 包括很多内容 )
  7. 根据指定的运行级别 (runlevel) 来运行服务器脚本程序,再执行脚本 /etc/rc.d/rc.local
  8. 运行一些其他的特别服务,一般为 /sbin/mingetty 和 /etc/X11/prefdm
  9. Linux 控制台 (console) 提示用户输入用户名、密码进行登陆。
    总结: BIOS 初始化  检查外围设备  检查启动设备  读区 MBR

    2 、在 Linux 中常用的启动引导工具: grub lilo
    在 Linux 和 WINDOWS 两系统并存时就需要安装 GRUB ( Grand Unified Bootloader ), GRUB 被广泛地
    用于替代 lilo,GRUB 支持在启动时使用命令行模式 , 支持 md5 加密保护 还可以从 ext2/ext3 、 ReiseFS 、 JFS 、
    FAT 、 minix 及 FFS 文件系统上启动其配置文件为 /boot/grub/grub.conf, 更改 grub.conf 即可立时生效如果
    硬盘上的 MBR 被更动过,可以用 /sbin/grub-install /dev/hda 来重安装 grub 现在我们打开
    /boot/grub/grub.conf 查看一下

vim /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/sda2 # initrd /initrd-version.img

#boot=/dev/sda
default=0
#default=0 表示默认启动第一个系统 , 如果系统有两个系统是用什么做为分隔符的呢? title 就是系统的分
隔符 , 第一个 title 后面就是第一个系统 , 用 0 表示。
timeout=5
#timout=5 ,就是默认在启动选择界面停留的时间,单位是秒。等待 5 秒自动进入默认操作系统
splashimage=(hd0,0)/grub/splash.xpm.gz
#splashimage 是 grub 启动背景画面,如果是自己写 grub.conf 文件,这个可以不用写。
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
#title 后面就是系统在启动时候显示的名字
root (hd0,0)
#root 启动文件所在位置
kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet
#kernel 内核所在位置和名字
initrd /initrd-2.6.18-53.el5.img
#initrd 内核镜象的名字
grub.conf 的范例:
timeout=10 # 等待 10 秒自动进入默认操作系统
splashimage=(hd0,0)/grub/splash.xpm.gz #grub 启动背景画面
default=0 # 默认进入第一个标题
title Red Hat Linux (2.4.20-18) #Red Hat Linux 标题
root (hd0,0) # 根文件系统位置
kernel /vmlinuz-2.4.20-18 ro root=LABEL=/ # 核心位置与核心加载参数
initrd /initrd-2.4.20-18.img # 启动 initrd ram 盘
title windows # 另一个操作系统的标题
rootnoverify (hd0,1) # 操作系统存放在 hd0,1 上,不要在 grub 里 mount
chainloader +1 # 从 hd0,1 的第一个扇面启动

相关推荐
梁正雄1 天前
linux服务-Bonding网卡绑定工具
linux·运维·linux bonding·网卡绑定
云边有个稻草人1 天前
Windows 里用 Linux 不卡顿?WSL + cpolar让跨系统开发变简单
linux·运维·服务器·cpolar
打不了嗝 ᥬ᭄1 天前
【Linux】网络层协议
linux·网络·c++·网络协议·http
LXY_BUAA1 天前
将linux操作系统装入U盘20251107
linux·运维·服务器
lingggggaaaa1 天前
小迪安全v2023学习笔记(一百四十五讲)—— Webshell篇&魔改冰蝎&打乱特征指纹&新增加密协议&过后门查杀&过流量识别
笔记·学习·安全·魔改冰蝎·免杀对抗·免杀技术
kaoa0001 天前
Linux入门攻坚——53、drbd - Distribute Replicated Block Device,分布式复制块设备-2
linux·运维·服务器
Digitally1 天前
如何将iPhone上的笔记传输到电脑
笔记·电脑·iphone
落羽的落羽1 天前
【C++】现代C++的新特性constexpr,及其在C++14、C++17、C++20中的进化
linux·c++·人工智能·学习·机器学习·c++20·c++40周年
RisunJan1 天前
Linux命令-e2label命令(设置第二扩展文件系统的卷标)
linux·运维·服务器
Claire_ccat1 天前
2025山西省网络安全职业技能大赛PWN方向题解
linux·安全·网络安全·pwn·栈溢出