MBR2GPT.EXEMBR2GPT.EXE

适用于Applies to

  • Windows10Windows 10

摘要Summary

MBR2GPT.EXE 可将磁盘从主启动记录 (MBR) 转换为 GUID 分区表 (GPT) 分区形式,无需修改或删除磁盘上的数据。MBR2GPT.EXE converts a disk from the Master Boot Record (MBR) to the GUID Partition Table (GPT) partition style without modifying or deleting data on the disk. 该工具旨在从 Windows 预安装环境 (Windows PE) 命令提示符运行,但也可以通过使用 /allowFullOS 选项从完整的 Windows 10 操作系统 (OS) 运行。The tool is designed to be run from a Windows Preinstallation Environment (Windows PE) command prompt, but can also be run from the full Windows 10 operating system (OS) by using the /allowFullOS option.

MBR2GPT.EXE 位于运行 Windows 10 版本 1703(又称为创意者更新)或更高版本的计算机的 Windows\System32 目录下。MBR2GPT.EXE is located in the Windows\System32 directory on a computer running Windows 10 version 1703 (also known as the Creator's Update) or later. 该工具也在完整的操作系统环境和 Windows PE 中提供。The tool is available in both the full OS environment and Windows PE. 若要在使用配置管理器或 Microsoft 部署工具包 (MDT) 的部署任务序列中使用此工具,必须先使用 Windows ADK 1703 或更高版本更新 Windows PE 映像(winpe.wim、boot.wim)。To use this tool in a deployment task sequence with Configuration Manager or Microsoft Deployment Toolkit (MDT), you must first update the Windows PE image (winpe.wim, boot.wim) with the Windows ADK 1703, or a later version.

请观看下面的视频查看 MBR2GPT 的详细说明和演示。See the following video for a detailed description and demonstration of MBR2GPT.

可以使用 MBR2GPT 执行以下操作:You can use MBR2GPT to:

  • 将任意连接的 MBR 格式化系统磁盘转换为 GPT 分区格式。Convert any attached MBR-formatted system disk to the GPT partition format. 你无法使用该工具将非系统磁盘从 MBR 转换为 GPT。You cannot use the tool to convert non-system disks from MBR to GPT.
  • 转换带有 BitLocker 加密的卷的 MBR 磁盘,只要保护已挂起。Convert an MBR disk with BitLocker-encrypted volumes as long as protection has been suspended. 要在转换后恢复 BitLocker,需要删除现有保护程序并重新创建。To resume BitLocker after conversion, you will need to delete the existing protectors and recreate them.
  • 转换安装了较早版本的 Windows 10(例如版本 1507、1511 和 1607)的操作系统磁盘。Convert operating system disks that have earlier versions of Windows 10 installed, such as versions 1507, 1511, and 1607. 但是,必须在启动到 Windows 10 版本 1703 或更高版本时运行该工具,并执行脱机转换。However, you must run the tool while booted into Windows 10 version 1703 or later, and perform an offline conversion.
  • 使用配置管理器或 MDT 将操作系统磁盘从 MBR 转换为 GPT,前提是任务序列使用 Windows PE 版本 1703 或更高版本。Convert an operating system disk from MBR to GPT using Configuration Manager or MDT provided that your task sequence uses Windows PE version 1703 or later.

脱机转换安装了较早版本的 Windows(例如 Windows 7、8 或 8.1)的系统磁盘不受正式支持。Offline conversion of system disks with earlier versions of Windows installed, such as Windows 7, 8, or 8.1 are not officially supported. 建议的转换这些磁盘的方法是,先升级到 Windows 10 操作系统,再执行 MBR 到 GPT 的转换。The recommended method to convert these disks is to upgrade the operating system to Windows 10 first, then perform the MBR to GPT conversion.

重要

磁盘转换为 GPT 分区形式后,必须重新配置固件才能以 UEFI 模式启动。After the disk has been converted to GPT partition style, the firmware must be reconfigured to boot in UEFI mode.
尝试转换磁盘之前,请确保你的设备支持 UEFI。Make sure that your device supports UEFI before attempting to convert the disk.

磁盘必备条件Disk Prerequisites

对磁盘进行任何更改之前,MBR2GPT 会验证所选磁盘的布局和几何图形,以确保:Before any change to the disk is made, MBR2GPT validates the layout and geometry of the selected disk to ensure that:

  • 磁盘正在使用 MBRThe disk is currently using MBR
  • 有足够的分区未占用空间可以存储主要和辅助 GPT:There is enough space not occupied by partitions to store the primary and secondary GPTs:
    • 磁盘前部有 16 KB + 2 个扇区16KB + 2 sectors at the front of the disk
    • 磁盘后部有 16 KB + 1 个扇区16KB + 1 sector at the end of the disk
  • MBR 分区表中最多有 3 个主分区There are at most 3 primary partitions in the MBR partition table
  • 其中一个分区被设置为活动,并作为系统分区One of the partitions is set as active and is the system partition
  • 磁盘没有任何扩展/逻辑分区。The disk does not have any extended/logical partition
  • 系统分区中的 BCD 存储包含一个指向 OS 分区的默认 OS 项The BCD store on the system partition contains a default OS entry pointing to an OS partition
  • 可以为每个具有已分配驱动器号的卷检索卷 IDThe volume IDs can be retrieved for each volume which has a drive letter assigned
  • 磁盘上的所有分区均为 Windows 可识别的 MBR 类型,或具有使用 /map 的命令行选项指定的映射All partitions on the disk are of MBR types recognized by Windows or has a mapping specified using the /map command-line option

如果任意检查失败,将不会继续转换,并将返回错误。If any of these checks fails, the conversion will not proceed and an error will be returned.

语法Syntax

MBR2GPT/validate | convert [/disk: < diskNumber>] [/logs: < logDirectory>] [/map: < source>= < destination>] [/allowFullOS]MBR2GPT /validate|convert [/disk:<diskNumber>] [/logs:<logDirectory>] [/map:<source>=<destination>] [/allowFullOS]

选项Options

选项Option 描述Description
/validate/validate 指示 MBR2GPT.exe 仅执行磁盘验证步骤,并报告磁盘是否有资格进行转换。Instructs MBR2GPT.exe to perform only the disk validation steps and report whether the disk is eligible for conversion.
/convert/convert 指示 MBR2GPT.exe 执行磁盘验证,如果通过所有验证测试,可继续进行转换。Instructs MBR2GPT.exe to perform the disk validation and to proceed with the conversion if all validation tests pass.
磁盘/disk:<diskNumber> 指定转换为 GPT 的磁盘编号。Specifies the disk number of the disk to be converted to GPT. 如果不指定,则使用系统磁盘。If not specified, the system disk is used. 所用机制与 diskpart.exe 工具 SELECT DISK SYSTEM 命令使用的机制相同。The mechanism used is the same as that used by the diskpart.exe tool SELECT DISK SYSTEM command.
logs/logs:<logDirectory> 指定应写入 MBR2GPT.exe 日志的目录。Specifies the directory where MBR2GPT.exe logs should be written. 如果不指定,则使用 %windir%If not specified, %windir% is used. 如果指定,目录必须已经存在,它不会自动创建或被覆盖。If specified, the directory must already exist, it will not be automatically created or overwritten.
.map<source>=/map:<source>=<destination> 指定 MBR 和 GPT 之间的其他分区类型映射。Specifies additional partition type mappings between MBR and GPT. MBR 分区号以十进制数形式指定,而不是十六进制。The MBR partition number is specified in decimal notation, not hexadecimal. GPT GUID 可以包含括号,例如:/map:42 = {af9b60a0-1431-4f62-bc68-3311714a69ad}The GPT GUID can contain brackets, for example: /map:42={af9b60a0-1431-4f62-bc68-3311714a69ad}. 如果需要多个映射,可指定 Multiple /map 选项。Multiple /map options can be specified if multiple mappings are required.
/allowFullOS/allowFullOS 默认情况下会阻止 MBR2GPT.exe,除非从 Windows PE 运行。By default, MBR2GPT.exe is blocked unless it is run from Windows PE. 在完整的 Windows 环境中运行时,该选项将覆盖此块,并启用磁盘转换。This option overrides this block and enables disk conversion while running in the full Windows environment.
注意:现有 MBR 系统分区正在使用并运行完整的 Windows 环境,因此无法重复使用。Note: Since the existing MBR system partition is in use while running the full Windows environment, it cannot be reused. 在这种情况下,系统会通过压缩操作系统分区来创建新 ESP。In this case, a new ESP is created by shrinking the OS partition.

示例Examples

验证示例Validation example

在以下示例中,对磁盘 0 进行转换验证。In the following example, disk 0 is validated for conversion. 错误和警告记录在默认位置,%windir%Errors and warnings are logged to the default location, %windir%.

X:\>mbr2gpt /validate /disk:0
MBR2GPT: Attempting to validate disk 0
MBR2GPT: Retrieving layout of disk
MBR2GPT: Validating layout, disk sector size is: 512
MBR2GPT: Validation completed successfully

转换示例Conversion example

在以下示例中:In the following example:

  1. 使用 DiskPart,在转换之前显示当前的磁盘分区布局 - MBR 磁盘(磁盘 0)上存在三个分区:系统保留分区、Windows 分区和恢复分区。Using DiskPart, the current disk partition layout is displayed prior to conversion - three partitions are present on the MBR disk (disk 0): a system reserved partition, a Windows partition, and a recovery partition. DVD-ROM 也作为卷 0 存在。A DVD-ROM is also present as volume 0.
  2. 选择 OS 卷、列出分区、并显示 OS 分区的分区详细信息。The OS volume is selected, partitions are listed, and partition details are displayed for the OS partition. 对应于可安装的文件系统 (IFS) 类型,MBR 分区类型07The MBR partition type is 07 corresponding to the installable file system (IFS) type.
  3. MBR2GPT 工具用于转换磁盘 0。The MBR2GPT tool is used to convert disk 0.
  4. DiskPart 工具显示磁盘 0 正在使用 GPT 格式。The DiskPart tool displays that disk 0 is now using the GPT format.
  5. 显示新的磁盘布局 - GPT 磁盘上存在四个分区:三个与之前的分区相同,一个是新的 EFI 系统分区(卷 3)。The new disk layout is displayed - four partitions are present on the GPT disk: three are identical to the previous partitions and one is the new EFI system partition (volume 3).
  6. 再次选择 OS 卷,详细信息显示它已被转换为 GPT 分区类型 ebd0a0a2-b9e5-4433-87c0-68b6b72699c7(对应于 PARTITION_BASIC_DATA_GUID 类型)。The OS volume is selected again, and detail displays that it has been converted to the GPT partition type of ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 corresponding to the PARTITION_BASIC_DATA_GUID type.

如 MBR2GPT 工具的输出中所述,你必须更改计算机固件,新的 EFI 系统分区才能正常启动。As noted in the output from the MBR2GPT tool, you must make changes to the computer firmware so that the new EFI system partition will boot properly.

X:\>DiskPart

Microsoft DiskPart version 10.0.15048.0

Copyright (C) Microsoft Corporation.
On computer: MININT-K71F13N

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     F   CENA_X64FRE  UDF    DVD-ROM     4027 MB  Healthy
  Volume 1     C   System Rese  NTFS   Partition    499 MB  Healthy
  Volume 2     D   Windows      NTFS   Partition     58 GB  Healthy
  Volume 3     E   Recovery     NTFS   Partition    612 MB  Healthy    Hidden

DISKPART> select volume 2

Volume 2 is the selected volume.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary            499 MB  1024 KB
* Partition 2    Primary             58 GB   500 MB
  Partition 3    Recovery           612 MB    59 GB

DISKPART> detail partition

Partition 2
Type  : 07
Hidden: No
Active: No
Offset in Bytes: 524288000

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 2     D   Windows      NTFS   Partition     58 GB  Healthy

DISKPART> exit

Leaving DiskPart...

X:\>mbr2gpt /convert /disk:0

MBR2GPT will now attempt to convert disk 0.
If conversion is successful the disk can only be booted in GPT mode.
These changes cannot be undone!

MBR2GPT: Attempting to convert disk 0
MBR2GPT: Retrieving layout of disk
MBR2GPT: Validating layout, disk sector size is: 512 bytes
MBR2GPT: Trying to shrink the system partition
MBR2GPT: Trying to shrink the OS partition
MBR2GPT: Creating the EFI system partition
MBR2GPT: Installing the new boot files
MBR2GPT: Performing the layout conversion
MBR2GPT: Migrating default boot entry
MBR2GPT: Adding recovery boot entry
MBR2GPT: Fixing drive letter mapping
MBR2GPT: Conversion completed successfully
MBR2GPT: Before the new system can boot properly you need to switch the firmware to boot to UEFI mode!

X:\>DiskPart

Microsoft DiskPart version 10.0.15048.0

Copyright (C) Microsoft Corporation.
On computer: MININT-K71F13N

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online           60 GB      0 B        *

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     F   CENA_X64FRE  UDF    DVD-ROM     4027 MB  Healthy
  Volume 1     D   Windows      NTFS   Partition     58 GB  Healthy
  Volume 2     C   System Rese  NTFS   Partition    499 MB  Healthy    Hidden
  Volume 3                      FAT32  Partition    100 MB  Healthy    Hidden
  Volume 4     E   Recovery     NTFS   Partition    612 MB  Healthy    Hidden

DISKPART> select volume 1

Volume 1 is the selected volume.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Recovery           499 MB  1024 KB
* Partition 2    Primary             58 GB   500 MB
  Partition 4    System             100 MB    59 GB
  Partition 3    Recovery           612 MB    59 GB

DISKPART> detail partition

Partition 2
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 524288000

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 1     D   Windows      NTFS   Partition     58 GB  Healthy

规格Specifications

磁盘转换工作流Disk conversion workflow

后续步骤演示了 MBR 到 GPT 转换过程的高级阶段:The following steps illustrate high-level phases of the MBR-to-GPT conversion process:

  1. 已执行磁盘验证。Disk validation is performed.
  2. 如果不存在,请对磁盘进行重新分区,以创建 EFI 系统分区 (ESP)。The disk is repartitioned to create an EFI system partition (ESP) if one does not already exist.
  3. 已将 UEFI 启动文件安装到 ESP。UEFI boot files are installed to the ESP.
  4. 应用 GPT 元数据和布局信息。GPT metadata and layout information is applied.
  5. 已更新引导配置数据 (BCD) 存储。The boot configuration data (BCD) store is updated.
  6. 已恢复驱动器号分配。Drive letter assignments are restored.

创建 EFI 系统分区Creating an EFI system partition

为使 windows 在转换后保持可启动,EFI 系统分区 (ESP) 必须到位。For Windows to remain bootable after the conversion, an EFI system partition (ESP) must be in place. MBR2GPT 使用以下规则创建 ESP:MBR2GPT creates the ESP using the following rules:

  1. 如果满足以下要求,则重新使用现有 MBR 系统分区:The existing MBR system partition is reused if it meets these requirements:
    a.a. 它不是 OS 或 Windows 恢复环境分区。It is not also the OS or Windows Recovery Environment partition.
    b.b. 大小至少为 100 MB(或,4K 扇区磁盘为 260 MB)。It is at least 100MB (or 260MB for 4K sector size disks) in size.
    c.c. 大小小于或等于 1 GB。It is less than or equal to 1GB in size. 这是一项安全措施,可确保它不是数据分区。This is a safety precaution to ensure it is not a data partition.
    d.d. 转换不是从完整的操作系统执行。The conversion is not being performed from the full OS. 在这种情况下,现有的 MBR 系统分区正在使用,不能重复使用。In this case, the existing MBR system partition is in use and cannot be repurposed.
  2. 如果不能重新使用现有的 MBR 系统分区,请通过压缩 OS 分区创建新 ESP。If the existing MBR system partition cannot be reused, a new ESP is created by shrinking the OS partition. 此新分区的大小为 100 MB(或,4K 扇区磁盘为 260 MB)并格式化为 FAT32。This new partition has a size of 100MB (or 260MB for 4K sector size disks) and is formatted FAT32.

如果现有 MBR 系统分区无法供 ESP 重复使用,则其转换后不会再用于启动过程。If the existing MBR system partition is not reused for the ESP, it is no longer used by the boot process after the conversion. 其他分区不会修改。Other partitions are not modified.

重要

如果现有的 MBR 系统分区没有重复用于 ESP,说明它可能被分配了驱动器号。If the existing MBR system partition is not reused for the ESP, it might be assigned a drive letter. 如果你不希望使用这个小分区,则必须手动隐藏驱动器号。If you do not wish to use this small partition, you must manually hide the drive letter.

分区类型映射和分区属性Partition type mapping and partition attributes

由于 GPT 分区使用的类型 ID 集与 MBR 分区不同,因此,必须为转换后的磁盘上的每个分区分配一个新的类型 ID。Since GPT partitions use a different set of type IDs than MBR partitions, each partition on the converted disk must be assigned a new type ID. 分区类型映射遵循以下规则:The partition type mapping follows these rules:

  1. ESP 始终设置为分区类型 PARTITION_SYSTEM_GUID (c12a7328-f81f-11d2-ba4b-00a0c93ec93b)。The ESP is always set to partition type PARTITION_SYSTEM_GUID (c12a7328-f81f-11d2-ba4b-00a0c93ec93b).
  2. 如果 MBR 分区类型与 /map 开关中指定的任一条目匹配,则使用指定的 GPT 分区类型 ID。If an MBR partition is of a type that matches one of the entries specified in the /map switch, the specified GPT partition type ID is used.
  3. 如果 MBR 分区的类型为 0x27,则将分区转换为 PARTITION_MSFT_RECOVERY_GUID (de94bba4-06d1-4d40-a16a-bfd50179d6ac) 类型的 GPT 分区。If the MBR partition is of type 0x27, the partition is converted to a GPT partition of type PARTITION_MSFT_RECOVERY_GUID (de94bba4-06d1-4d40-a16a-bfd50179d6ac).
  4. 所有其他 Windows 可识别的 MBR 分区转换为 PARTITION_BASIC_DATA_GUID (ebd0a0a2-b9e5-4433-87c0-68b6b72699c7) 类型的 GPT 分区。All other MBR partitions recognized by Windows are converted to GPT partitions of type PARTITION_BASIC_DATA_GUID (ebd0a0a2-b9e5-4433-87c0-68b6b72699c7).

除应用正确的分区类型外,PARTITION_MSFT_RECOVERY_GUID 类型的分区还具有以下 GPT 属性集:In addition to applying the correct partition types, partitions of type PARTITION_MSFT_RECOVERY_GUID also have the following GPT attributes set:

  • GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001)GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001)
  • GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000)GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000)

有关分区类型的详细信息,请参阅:For more information about partition types, see:

保持驱动器号分配Persisting drive letter assignments

转换工具将尝试重新映射注册表中包含的所有驱动器号分配信息,其对应于已转换磁盘的卷。The conversion tool will attempt to remap all drive letter assignment information contained in the registry that correspond to the volumes of the converted disk. 如果无法恢复分配驱动器号,控制台和在日志中将显示错误,以便你可以手动执行正确的驱动器号分配。If a drive letter assignment cannot be restored, an error will be displayed at the console and in the log, so that you can manually perform the correct assignment of the drive letter. 重要提示:此代码布局转换发生之后运行,因此无法在此阶段撤消操作。Important: this code runs after the layout conversion has taken place, so the operation cannot be undone at this stage.

转换工具将在布局转换之前和之后获取卷的唯一 ID 数据,并将此信息组织到查找表中。The conversion tool will obtain volume unique ID data before and after the layout conversion, organizing this information into a lookup table. 然后,它会在 HKLM\SYSTEM\MountedDevices 中的所有条目中进行迭代,请为每个条目执行以下操作:It will then iterate through all the entries in HKLM\SYSTEM\MountedDevices, and for each entry do the following:

  1. 检查唯一 ID 是否对应于作为已转换磁盘的一部分的任意卷的任意唯一 ID。Check if the unique ID corresponds to any of the unique IDs for any of the volumes that are part of the converted disk.
  2. 如果找到,请将布局转换后获取的值设置为新的唯一 ID。If found, set the value to be the new unique ID, obtained after the layout conversion.
  3. 如果无法设置新的唯一 ID 且值名称以 \DosDevices 开头,请发布一条有关需要手动干预以正确还原驱动器号分配的控制台和日志警告。If the new unique ID cannot be set and the value name starts with \DosDevices, issue a console and log warning about the need for manual intervention in properly restoring the drive letter assignment.

疑难解答Troubleshooting

该工具将在其输出中显示状态信息。The tool will display status information in its output. 如果遇到任何错误,将取消验证和转换。Both validation and conversion are clear if any errors are encountered. 例如,如果一个或多个分区未正确转换,将显示这一信息,并且无法执行转换。For example, if one or more partitions do not translate properly, this is displayed and the conversion not performed. 要查看有关遇到的任何错误的详细信息,请参阅关联的日志文件To view more detail about any errors that are encountered, see the associated log files.

日志Logs

通过 MBR2GPT 工具创建四个日志文件:Four log files are created by the MBR2GPT tool:

  • diagerr.xmldiagerr.xml
  • diagwrn.xmldiagwrn.xml
  • setupact.logsetupact.log
  • setuperr.logsetuperr.log

这些文件包含在磁盘验证和转换期间遇到的错误和警告。These files contain errors and warnings encountered during disk validation and conversion. 这些文件中的信息有助于诊断工具的问题。Information in these files can be helpful in diagnosing problems with the tool. setupact.log 和 setuperr.log 文件将提供有关磁盘布局、进程的最详细信息和与磁盘验证和转换有关的其他信息。The setupact.log and setuperr.log files will have the most detailed information about disk layouts, processes, and other information pertaining to disk validation and conversion. 注意:setupact*.log 文件与在 %Windir%\Panther 目录中找到的 Windows 安装程序文件不同。Note: The setupact*.log files are different than the Windows Setup files that are found in the %Windir%\Panther directory.

Windows PE 中的所有这些日志文件的默认位置是 %windir%The default location for all these log files in Windows PE is %windir%.

交互式帮助Interactive help

要查看使用工具时的可用选项列表,请键入 mbr2gpt /?To view a list of options available when using the tool, type mbr2gpt /?

显示下列文本:The following text is displayed:


C:\> mbr2gpt /?

Converts a disk from MBR to GPT partitioning without modifying or deleting data on the disk.

MBR2GPT.exe /validate|convert [/disk:<diskNumber>] [/logs:<logDirectory>] [/map:<source>=<destination>] [/allowFullOS]

Where:

 /validate
         - Validates that the selected disk can be converted
           without performing the actual conversion.

 /convert
         - Validates that the selected disk can be converted
           and performs the actual conversion.

 /disk:<diskNumber>
         - Specifies the disk number of the disk to be processed.
           If not specified, the system disk is processed.

 /logs:<logDirectory>
         - Specifies the directory for logging. By default logs
           are created in the %windir% directory.

 /map:<source>=<destination>
         - Specifies the GPT partition type to be used for a
           given MBR partition type not recognized by Windows.
           Multiple /map switches are allowed.

 /allowFullOS
         - Allows the tool to be used from the full Windows
           environment. By default, this tool can only be used
           from the Windows Preinstallation Environment.

返回代码Return codes

MBR2GPT 具有以下关联的返回代码:MBR2GPT has the following associated return codes:

返回代码Return code 描述Description
00 已成功完成转换。Conversion completed successfully.
raid-11 用户已取消转换。Conversion was canceled by the user.
ppls-22 由于内部错误,转换失败。Conversion failed due to an internal error.
三维空间3 由于初始化错误,转换失败。Conversion failed due to an initialization error.
4 由于无效的命令行参数,转换失败。Conversion failed due to invalid command-line parameters.
5 由于读取所选磁盘的几何图形和布局出现错误,转换失败。Conversion failed due to error reading the geometry and layout of the selected disk.
6 由于磁盘上的一个或多个卷已加密,转换失败。Conversion failed because one or more volumes on the disk is encrypted.
77 由于所选磁盘的几何图形和布局不符合要求,转换失败。Conversion failed because the geometry and layout of the selected disk do not meet requirements.
8 由于创建 EFI 系统分区时出现错误,转换失败。Conversion failed due to error while creating the EFI system partition.
db-99 由于安装启动文件时出现错误,转换失败。Conversion failed due to error installing boot files.
1010 由于应用 GPT 布局时发生错误,转换失败。Conversion failed due to error while applying GPT layout.
100100 已成功转换为 GPT 布局,但某些引导配置数据条目无法还原。Conversion to GPT layout succeeded, but some boot configuration data entries could not be restored.

确定分区类型Determining the partition type

你可以在 Windows PowerShell 提示符中键入以下命令来显示磁盘编号和分区类型。You can type the following command at a Windows PowerShell prompt to display the disk number and partition type. 示例输出如下所示:Example output is also shown:

PS C:\> Get-Disk | ft -Auto

Number Friendly Name      Serial Number        HealthStatus OperationalStatus Total Size Partition Style
------ -------------      -------------        ------------ ----------------- ---------- ---------------
0      MTFDDAK256MAM-1K1  13050928F47C         Healthy      Online             238.47 GB MBR
1      ST1000DM003-1ER162 Z4Y3GD8F             Healthy      Online             931.51 GB GPT

你还可以通过打开磁盘管理工具,右键单击磁盘编号,单击属性,然后单击选项卡查看磁盘的分区类型。请参见以下示例:You can also view the partition type of a disk by opening the Disk Management tool, right-clicking the disk number, clicking Properties, and then clicking the Volumes tab. See the following example:

卷

如果 Windows PowerShell 和磁盘管理不可用(例如,当你使用 Windows PE 时),你可以使用 DiskPart 工具在命令提示符中确定分区类型。If Windows PowerShell and Disk Management are not available, such as when you are using Windows PE, you can determine the partition type at a command prompt with the DiskPart tool. 若要从命令行确定分区形式,请键入 diskpart,然后键入 list diskTo determine the partition style from a command line, type diskpart and then type list disk. 请参见以下示例:See the following example:

X:\>DiskPart

Microsoft DiskPart version 10.0.15048.0

Copyright (C) Microsoft Corporation.
On computer: MININT-K71F13N

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          238 GB      0 B
  Disk 1    Online          931 GB      0 B        *

在此示例中,磁盘 0 使用 MBR 分区形式进行格式化,磁盘 1 使用 GPT 进行格式化。In this example, Disk 0 is formatted with the MBR partition style, and Disk 1 is formatted using GPT.

已知问题Known issue

MBR2GPT.exe 无法在 Windows PE 中运行MBR2GPT.exe cannot run in Windows PE

在 Windows 预安装环境中启动基于 Windows 10 版本1903的计算机 (Windows PE) 时,你会遇到以下问题:When you start a Windows 10, version 1903-based computer in the Windows Preinstallation Environment (Windows PE), you encounter the following issues:

问题 1 当运行 MBR2GPT.exe 命令时,进程将退出,而不转换驱动器。Issue 1 When you run the MBR2GPT.exe command, the process exits without converting the drive.

问题 2 当您在命令提示符窗口中手动运行 MBR2GPT.exe 命令时,该工具没有输出。Issue 2 When you manually run the MBR2GPT.exe command in a Command Prompt window, there is no output from the tool.

问题 3 当 MBR2GPT.exe 在图像处理过程(如 Microsoft 终结点配置管理器任务序列、MDT 任务序列或使用脚本)内运行时,将收到以下退出代码: 0xC0000135/3221225781。Issue 3 When MBR2GPT.exe runs inside an imaging process such as a Microsoft Endpoint Configuration Manager task sequence, an MDT task sequence, or by using a script, you receive the following exit code: 0xC0000135/3221225781.

原因Cause

出现此问题的原因是在 Windows 10 版本1903和更高版本中,MBR2GPT.exe 需要访问 ReAgent.dll 文件。This issue occurs because in Windows 10, version 1903 and later versions, MBR2GPT.exe requires access to the ReAgent.dll file. 但是,Windows 10 版本1903和更高版本的 Windows PE 启动映像中不包含此 dll 文件及其关联的库。However, this dll file and its associated libraries are currently not included in the Windows PE boot image for Windows 10, version 1903 and later.

解决方法Workaround

若要解决此问题,请将 Windows PE 映像安装 (WIM) ,从 Windows 10 版本1903评估和开发工具包 (ADK) 源复制缺少的文件,然后将更改提交到 WIM。To fix this issue, mount the Windows PE image (WIM), copy the missing file from the Windows 10, version 1903 Assessment and Development Kit (ADK) source, and then commit the changes to the WIM. 为此,请执行下列步骤:To do this, follow these steps:

  1. 将 Windows PE WIM 装载到路径 (例如,C:\ WinPE_Mount) 。Mount the Windows PE WIM to a path (for example, C:\WinPE_Mount). 有关如何装载 WIM 文件的详细信息,请参阅 装载映像For more information about how to mount WIM files, see Mount an image.

  2. 将 ReAgent 文件和 ReAgent 本地化文件从 Window 10 版本 1903 ADK 源文件夹复制到装载的 WIM。Copy the ReAgent files and the ReAgent localization files from the Window 10, version 1903 ADK source folder to the mounted WIM.

    例如,如果将 ADK 安装到 C:\Program 文件的默认位置 (x86) \Windows Kits\10,而 Windows PE 映像已装载到 C:\ WinPE_Mount,请从提升的命令提示符窗口运行以下命令:For example, if the ADK is installed to the default location of C:\Program Files (x86)\Windows Kits\10 and the Windows PE image is mounted to C:\WinPE_Mount, run the following commands from an elevated Command Prompt window:

    备注

    如果在安装 Windows 评估和部署工具包时 (USMT) 安装了 "用户状态迁移工具" 作为一项功能,则可以访问 ReAgent 文件。You can access the ReAgent files if you have installed the User State Migration Tool (USMT) as a feature while installing Windows Assessment and Deployment Kit.

    命令1:Command 1:

    copy "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Setup\amd64\Sources\ReAgent*.*" "C:\WinPE_Mount\Windows\System32"
    

    此命令将复制三个文件:This command copies three files:

    • ReAgentReAgent.admx
    • ReAgent.dllReAgent.dll
    • ReAgent.xmlReAgent.xml

    命令2:Command 2:

    copy "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Setup\amd64\Sources\En-Us\ReAgent*.*" "C:\WinPE_Mount\Windows\System32\En-Us"
    

    此命令将复制两个文件:This command copies two files:

    • ReAgent admlReAgent.adml
    • ReAgent.dll muiReAgent.dll.mui

    备注

    如果使用的不是英文版本的 Windows,请将路径中的 "En-us" 替换为表示系统语言的相应字符串。If you aren't using an English version of Windows, replace "En-Us" in the path with the appropriate string that represents the system language.

  3. 复制所有文件后,提交更改并卸载 Windows PE WIM。After you copy all the files, commit the changes and unmount the Windows PE WIM. MBR2GPT.exe 现在在 Windows PE 中按预期方式工作。MBR2GPT.exe now functions as expected in Windows PE. 有关如何在提交更改时卸载 WIM 文件的信息,请参阅 卸载映像For information about how to unmount WIM files while committing changes, see Unmounting an image.

相关主题Related topics

Windows 10 企业版系统要求Windows 10 Enterprise system requirements
Windows10 规范Windows 10 Specifications
Windows 10 IT 专业人员论坛Windows 10 IT pro forums