CentOS7 UEFI 转 BIOS 操作流程
1. 需求分析
源主机运行在VMware环境一台CentOS7.5系统,UEFI引导,GPT分区格式,现在需将这台VM迁移到OpenStack KVM环境下,由于KVM环境目前没有开放支持UEFI引导,需要将UEFI转换成BIOS标准引导,安装注入相关virtio驱动完成整个迁移动作。
2. 操作环境描述
源VMware待迁移VM信息如下:(下面简称:**迁移VM**
)
操作系统:CentOS Linux release 7.3.1611 (Core)
内核版本:3.10.0-514.el7.x86_64
引导方式:UEFI
磁盘分区:GPT分区
根分区:LVM格式
IP地址:192.168.10.83
磁盘信息:20G,/boot、/boot/efi、/
修复引导的Linux VM信息,这台主要用于挂载VMware VM的磁盘,然后在此VM上进行UEFI转换动作,这台VM运行与OpenStack平台,环境信息如下:(下面简称:**修复VM**
)
操作系统:CentOS Linux release 7.5.1804 (Core)
内核版本:3.10.0-862.3.2.el7.x86_64
IP地址:192.168.10.177
3. 步骤分解
迁移VM是UEFI引导,做转换之前需要先将迁移VM的磁盘复制或迁移到OpenStack平台,可以使用下载VMDK冷迁移或者热迁移工具,我这边采用HyperMotion将迁移VM主机磁盘数据热迁移只OpenStack平台,成为一个卷设备,然后再对卷设备进行UEFI转BIOS动作的处理,主要分为以下几个步骤:
1). 修复VM
安装UEFI转换指令
2). 挂载**迁移VM**
数据卷到**修复VM**
3). 修改**迁移VM**
磁盘分区类型
4). **迁移VM**
安装新的grub引导
5). 修改**迁移VM**
分区表
6). 添加virtio驱动
7). 创建虚拟机启动
3. 操作步骤
3.1.修复VM
安装UEFI转换指令
在修复VM系统内部,需要安装UEFI转换所的操作指令,需要提前安装gdisk等指令。
3.2. 挂载**迁移VM**
数据卷到**修复VM**
通过拷贝到openstack的卷快照,重新生成一个新的卷,然后挂载至修复VM上
3.3. 修改**迁移VM**
磁盘分区类型
迁移VM源磁盘为gpt分区,uefi引导,第一步我们需要将磁盘的gpt分区转换为mbr分区格式,其实这一步也可以不用转换,我们这里选择将gpt转换成mbr磁盘分区。
3.3.1. 转换磁盘gpt为mbr格式
### 源磁盘初始时可以看到为gpt分区表格式 ###
[root@centos7-transfer ~]# parted /dev/vde print
Model: Virtio Block Device (virtblk)
Disk /dev/vde: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB fat16 EFI System Partition boot
2 211MB 1285MB 1074MB xfs
3 1285MB 21.5GB 20.2GB lvm
3.3.2. 通过gdisk将分区表转换gpt为mbr格式
[root@centos7-transfer ~]# gdisk /dev/vde
GPT fdisk (gdisk) version 0.8.10
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): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Recovery/transformation command (? for help): g
MBR command (? for help): ?
a toggle the active/boot flag
c recompute all CHS values
l set partition as logical
o omit partition
p print the MBR partition table
q quit without saving changes
r set partition as primary
s sort MBR partitions
t change partition type code
w write the MBR partition table to disk and exit
MBR command (? for help): a
Toggle active flag for partition: