很久以前写过一篇《火眼仿真之windows引导修复》,主要讲gho转为vmdk后因为引导损坏导致windows虚拟机无法启动的问题。让我万万没想到的是,居然在用户调证某Linux系统的云服务器时某运营商居然交付的也是一个gho文件。本篇文章讲述Linux引导损坏时的解决方案,适用但不限于linux系统gho转vmdk导致无法启动问题。
-
准备工作(检查操作系统及重置用户密码)
火眼仿真检测操作系统
火眼仿真重置密码 -
下载对应操作系统iso
从上图可知,该Linux系统为CentOS7.6.1810,下载iso当修复光盘用。
清华大学源 -
虚拟机引导类型选择BIOS,加载系统ISO开机进livecd。
-
使用gdisk切换gpt分区表为MBR,骚操作如下:
[root@localhost liveuser]# yum install -y gdisk
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: ftp.sjtu.edu.cn
* updates: ftp.sjtu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gdisk.x86_64 0:0.8.10-2.el7 will be updated
---> Package gdisk.x86_64 0:0.8.10-3.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
gdisk x86_64 0.8.10-3.el7 base 190 k
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 190 k
Downloading packages:
No Presto metadata available for base
warning: /var/cache/yum/x86_64/7/base/packages/gdisk-0.8.10-3.el7.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for gdisk-0.8.10-3.el7.x86_64.rpm is not installed
gdisk-0.8.10-3.el7.x86_64.rpm | 190 kB 00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@base/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : gdisk-0.8.10-3.el7.x86_64 1/2
Cleanup : gdisk-0.8.10-2.el7.x86_64 2/2
Verifying : gdisk-0.8.10-3.el7.x86_64 1/2
Verifying : gdisk-0.8.10-2.el7.x86_64 2/2
Updated:
gdisk.x86_64 0:0.8.10-3.el7
Complete!
[root@localhost liveuser]# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10
The protective MBR's 0xEE partition is oversized! Auto-repairing.
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): r
Recovery/transformation command (? for help): g
MBR command (? for help): w
Converted 2 partitions. Finalize and exit? (Y/N): Y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
- 重装grub2 修复引导
[root@localhost liveuser]# mkdir root
[root@localhost liveuser]# mount /dev/sda1 root
[root@localhost liveuser]# mount --bind /dev root/dev
[root@localhost liveuser]# mount --bind /proc root/proc
[root@localhost liveuser]# mount --bind /sys root/sys
[root@localhost liveuser]# mount --bind /dev/pts root/dev/pts
[root@localhost liveuser]# mount --bind /dev/shm root/dev/shm
[root@localhost liveuser]# chroot root
[root@localhost /]# update-grub2
[root@localhost /]# grub2-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
- 重启,去掉系统ISO,进系统
网友评论