[Linux学习笔记] Linux系统引导流程(二)

本文详细解析了GRUB配置文件grub.conf的使用方法,包括默认设置、等待时间、GRUB界面图片、单用户模式启动及GRUB密码设置等。同时介绍了如何通过GRUB命令行进行系统修复和手动引导启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GRUB的配置文件:

软链接: /etc/grub.conf;文件位置: /boot/grub/grub.conf

下面给出grub.conf配置文件并就相关配置项进行说明:

[root@collect3 grub]# cat 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/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0    # default定义缺省启动系统
timeout=5    # timeout定义缺省等待时间
splashimage=(hd0,0)/grub/splash.xpm.gz    # splashimage定义GRUB界面图片(hd0,0)表示/boot分区<hd表示硬盘,参数1:hd0表示第一块硬盘,参数2:0表示第一个分区>
hiddenmenu    # hiddenmenu隐藏菜单
title GreatTurbo Enterprise Server (2.6.9-78.ELhugemem)    # title定义菜单项名称
	root (hd0,0)
	kernel /vmlinuz-2.6.9-78.ELhugemem ro root=/dev/VolGroup00/LogVol00 acpi=on    # 定义内核文件所在位置(/boot目录下)
	initrd /initrd-2.6.9-78.ELhugemem.img    # 命令加载镜像文件
title GreatTurbo Enterprise Server-smp (2.6.9-78.ELsmp)

单用户模式:

(1) 系统启动过程中按Esc键进入GRUB界面;

091949_WmPK_2265030.png

(2) GRUB界面按e进行编辑行模式,选中kernel行,再次按e键,在新的界面的最后一行输入1或s,即可进行单用户模式. Enter回车保存后,再次跳到GRUB界面;

092027_RgS6_2265030.png

(3) 按b键重新引导boot.

(4) 重新启动后将进入单用户模式,该模式下无图形界面,无需密码即可进入root用户命令行。此时可以修改root密码

设置GRUB密码:

[root@localhost ~]# grub-md5-crypt
Password: 
Retype password: 
$1$HDiFX$CfZRdJWPYkb5qq2w8lhKw/
[root@localhost ~]# grub
Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> md5crypt
md5crypt
Password: 123456
123456
Encrypted: $1$GViFX$JlugRZWB7bfs3RQfe./th.
grub> quit

如此我们获得了md5加密后的串,接下来修改grub.conf文件,加入行:

password --md5 $1$GViFX$JlugRZWB7bfs3RQfe./th.

系统重新启动后,进入GRUB界面如下截图:

092100_Efe6_2265030.png

系统修复及手动引导启动:

(1) GRUB命令行手工方式引导;

(2) 光盘引导

1.把安装盘放到光驱,然后重新启动机器,在BIOS中指定系统为光驱引导l
2.等待安装界面显示后,按[F5]键进入Linux Rescue模式
3.sh#命令行修复

下面来简单介绍一下CentOS-7如何进入到单用户模式修改root密码:

(1) 系统开始启动时,按下ESC键,进入GRUB界面

(2) GRUB界面截图如下:

084127_5L5a_2265030.png

(3) 修改框住的"ro",键入rw init=/sysroot/bin/sh

084234_CcTE_2265030.png

(4) 进入单用户模式,输入命令:

:/# chroot /sysroot    #访问系统
:/# passwd root    #重置root密码
:/# touch /.autorelabel    #更新系统信息
:/# exit    #退出chroot
exit
:/# reboot



转载于:https://my.oschina.net/LvSantorini/blog/535246

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值