解決CentOS7,EFI+GPT卡在grub,無法正常啓動的故障(一)

Linux系統故障,Grub丟失。開啓啓動後,直接進入grub>無法進入系統。
只需要刪除/boot/grub2/grub.cfg即可。 通過傳統的刪除硬盤的前446字節對GPT分區無效。

一、查看分區
解決CentOS7,EFI+GPT卡在grub,無法正常啓動的故障(一)

二、 臨時修復啓動

insmod xfs
set root='hd0,gpt2'                      #這裏指定的應該是/boot分區,這個分區下應該有 vmlinuz-0-rescue以及initramfs-0-rescue文件。
linuxefi /vmlinuz-0-rescue-9d20b497512743d8befa1a3151a40d24 root=/dev/mapper/centos-root            
                                                    #因爲有獨立的boot分區,所以linuxefi 後面可以直接跟/vmlinuz,該文件存放位於/boot下
initrdefi /initramfs-0-rescue-9d20b497512743d8befa1a3151a40d24.img
boot

解決CentOS7,EFI+GPT卡在grub,無法正常啓動的故障(一)

三、 啓動後,進入系統,安裝grub
[root@centos2 ~]# grub2-install /dev/sda
grub2-install:錯誤: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.

四、 解決上述報錯
[root@centos2 ~]# mount #查看光盤掛載
/dev/sr0 on /run/media/root/CentOS 7 x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
[root@centos2 ~]# cd /run/media/root/CentOS\ 7\ x86_64/

[root@centos2 CentOS 7 x86_64]# rpm -ivh Packages/grub2-efi-x64-2.02-0.80.el7.centos.x86_64.rpm
錯誤:依賴檢測失敗:
grub2-common = 1:2.02-0.80.el7.centos 被 grub2-efi-x64-1:2.02-0.80.el7.centos.x86_64 需要
grub2-tools = 1:2.02-0.80.el7.centos 被 grub2-efi-x64-1:2.02-0.80.el7.centos.x86_64 需要
grub2-tools-extra = 1:2.02-0.80.el7.centos 被 grub2-efi-x64-1:2.02-0.80.el7.centos.x86_64 需要

所以改用yum
[root@centos2 CentOS 7 x86_64]# yum -y install grub2-efi-x64-modules.noarch

[root@centos2 CentOS 7 x86_64]# grub2-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.

[root@centos2 grub2]# pwd
/boot/grub2
[root@centos2 grub2]# ls
fonts grub.cfg grubenv grubenv.rpmsave locale x86_64-efi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章