1. 将UEFI類型卷挂載到linux作業系統
windows 2008、windows2016 均通過測試可行,其他作業系統版本待測試。(阿裡雲平台測試通過)
1.2. GPT轉MBR操作
### 源GPT分區資訊
[[email protected] ~]# parted /dev/vdd print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 473MB 472MB ntfs Basic data partition hidden, diag
2 473MB 578MB 105MB fat32 EFI system partition boot
3 578MB 595MB 16.8MB Microsoft reserved partition msftres
4 595MB 42.9GB 42.4GB ntfs Basic data partition
1.2.1 執行轉換動作
注意:第一個啟動分區,一般為fat32,需要格式化為ntfs分區,并且将第一個啟動分區Code更改為0700标準的Basic data partition,并添加boot flag,需要通過fdisk t 來修改分區的type code為07
gdisk指令需要安裝包,yum install -y gdisk
[[email protected] ~]# gdisk /dev/vdd
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): p
Disk /dev/vdd: 83886080 sectors, 40.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 7C6851BB-9502-4194-A24F-14D52C03AAE8
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 83886046
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 923647 450.0 MiB 2700 Basic data partition
2 923648 1128447 100.0 MiB EF00 EFI system partition
3 1128448 1161215 16.0 MiB 0C01 Microsoft reserved ...
4 1161216 83884031 39.4 GiB 0700 Basic data partition
Command (? for help): r
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: 1
MBR command (? for help): w
Converted 4 partitions. Finalize and exit? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
[[email protected] ~]# parted /dev/vdd print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 473MB 472MB primary ntfs boot, diag
2 473MB 578MB 105MB primary fat32
3 578MB 595MB 16.8MB primary lba
4 595MB 42.9GB 42.4GB primary ntfs
1.2.2. 删除多餘分區(ESP、EFI)
删除第一個啟動分區的diag隐藏分區flags
[[email protected] ~]# mkfs.ntfs /dev/vdb1 # 需要安裝ntfsprogs包才可以
[[email protected] ~]# parted /dev/vdd -s rm 2
[[email protected] ~]# parted /dev/vdd -s rm 3
[[email protected] ~]# parted /dev/vdd -s toggle 1 diag
[[email protected] ~]# parted /dev/vdd print
Model: Virtio Block Device (virtblk)
Disk /dev/vdd: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 473MB 472MB primary ntfs boot
4 595MB 42.9GB 42.4GB primary ntfs
1.2.3. 目錄掃描修複
# ntfsfix /dev/vdd1
# ntfsfix /dev/vdd4
1.2.4. 執行驅動适配
驅動适配動作可以放到同架構windows下進行
(1)拷貝驅動檔案到指定目錄下。
(2)使用reg load指令加載bcd
(3)reg add指令添加所需驅動檔案及系統資料庫。
2. 挂載卷到windows機器進行bcd修複
2.1. 建立啟動檔案
從系統分區模版拷貝bcd啟動鏡像到指定boot分區
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIwczX0xiRGZkRGZ0Xy9GbvNGL2EzXlpXazxSP9cnW1Z0Vk9GczoVdsdUZxg2MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL1cDNyQDN1kDMxITNwEjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
2.2. 修複啟動配置資料
檢視bcd啟動配置資料
執行磁盤主引導mbr分區修複
目标發現阿裡雲的windows 2008 R2 英文版本沒有bootsect程式指令,需要進行移植使用,bootsect沒有以來庫檔案,可以提前儲存在遷移的環境中,檢查如果修複的windows 沒有此指令,就copy上使用,預設指令在 C:\windows\system32\ 目錄下
bootsect /nt60 d: /mbr # bootsect /nt60 <Boot partition>: /mbr
需要重建MBR主引導才可以正常啟動