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界面;
(2) GRUB界面按e进行编辑行模式,选中kernel行,再次按e键,在新的界面的最后一行输入1或s,即可进行单用户模式. Enter回车保存后,再次跳到GRUB界面;
(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界面如下截图:
系统修复及手动引导启动:
(1) GRUB命令行手工方式引导;
(2) 光盘引导
1.把安装盘放到光驱,然后重新启动机器,在BIOS中指定系统为光驱引导l
2.等待安装界面显示后,按[F5]键进入Linux Rescue模式
3.sh#命令行修复
下面来简单介绍一下CentOS-7如何进入到单用户模式修改root密码:
(1) 系统开始启动时,按下ESC键,进入GRUB界面
(2) GRUB界面截图如下:
(3) 修改框住的"ro",键入rw init=/sysroot/bin/sh
(4) 进入单用户模式,输入命令:
:/# chroot /sysroot #访问系统
:/# passwd root #重置root密码
:/# touch /.autorelabel #更新系统信息
:/# exit #退出chroot
exit
:/# reboot