CentOS 7在grub rescue模式中修复系统

安装完CentOS 7后 修改硬盘分区后,系统重启后,无法正常启动,进入grub rescue模式; 

网上大多数centos grub rescue的资料应该是Centos 7之前的,其中提到的命令很多使用的目录是grub,而在7中,这里应该替换成grub2;

另外normal.mod 的目录也有变化。特别要注意


1)首先找到centos 的boot是装在那个分区中;

1. 先使用ls命令
在 grub rescue>下输入以下命令:

ls

会罗列所有的磁盘分区信息,比方说:

引用:

(hd0,1),(hd0,5),(hd0,3),(hd0,2)
   注:我的是(hd0),(hd0,msdos3),(hd0,msdos5)等

2. 然后依次调用如下命令: X表示各个分区号码
如果/boot没有单独分区,用以下命令:

ls (hd0,X)/boot/grub2

如果/boot单独分区,则用下列命令:

ls (hd0,X)/grub2
例如:

grub rescue> ls (hd0,msdos2)/grub2

会有如下的输出:
 -grub2  grub  grub.cfg  i386-pc ...


2)

grub rescue> ls (hd0,msdos2)/grub2 // 找到/boot分区位置
--> grub2 grub grub.cfg i386-pc ...


grub rescue> set root=hd0,msdos2 // 临时重置grub位置为当前分区
grub rescue> set prefix=(hd0,msdos2)/grub2
grub rescue> insmod (hd0,msdos2)/grub2/i386-pc/normal.mod // 加载normal模块
grub rescue> normal // 调用normal模块


3)重新安装grub到sda
这时就出现了 grub引导菜单,选择进入CentOS系统

登录
login:root
passwd:*****

# cd /sbin
# grub2-install --boot-directory=/boot   /dev/sdb // 重新安装grub到sdb, 根据ls /dev/sd* 的结果,替换成你自己的硬盘

--> grub2-install completed, No Error occured.


# reboot

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值