MBR2GPT

Convert a disk from the Master Boot Record (MBR) to the GUID Partition Table (GPT) partition style without modifying or deleting data on the disk. The tool runs 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.

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

Key
   /validate 	     Instruct MBR2GPT.exe to perform only the disk validation steps and report whether
                     the disk is eligible for conversion.

   /convert 	      Instruct MBR2GPT.exe to perform the disk validation and to proceed with the conversion if
                     all validation tests pass.

   /disk:diskNumber  The disk number of the disk to be converted to GPT.
                     If not specified, the system disk is used. The mechanism used is the same as used by the
                     diskpart.exe tool SELECT DISK SYSTEM command.
   /logs:logDirectory
                     The directory where MBR2GPT.exe logs should be written.
                     If not specified, %windir% is used. If specified, the directory must already exist, it will
                     not be automatically created or overwritten.
   /map:source=destination
                     Specifies other partition type mappings between MBR and GPT.
                     The MBR partition number is specified in decimal notation, not hexadecimal.
                     The GPT GUID can contain brackets, for example: /map:42={af9b60a0-1431-4f62-bc68-3311714a69ad}.
                     Multiple /map options can be specified if multiple mappings are required.

   /allowFullOS 	 By default, MBR2GPT.exe is blocked unless it's run from Windows PE.
                     This option overrides this block and enables disk conversion while running in the full
                     Windows environment.

Note: Since the existing MBR system partition is in use while running the full Windows environment, it can't be reused. In this case, a new ESP is created by shrinking the OS partition.

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.

The conversion tool will attempt to remap all drive letter assignment information contained in the registry that corresponds to the volumes of the converted disk. If a drive letter assignment can't 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.

Logs

Four log files are created by MBR2GPT:

diagerr.xml
diagwrn.xml
setupact.log
setuperr.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. 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.

The setupact*.log files are different than the Windows Setup files that are found in the %Windir%\Panther directory.

The default location for all these log files in Windows PE is %windir%.

Return codes

Return code Description
0 Conversion completed successfully.
1 Conversion was canceled by the user.
2 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.
7 Conversion failed because the geometry and layout of the selected disk don't meet requirements.
8 Conversion failed due to error while creating the EFI system partition.
9 Conversion failed due to error installing boot files.
10 Conversion failed due to error while applying GPT layout.
100 Conversion to GPT layout succeeded, but some boot configuration data entries couldn't be restored.

Examples

disk 0 is validated for conversion. Errors and warnings are logged to the default location of %windir%.

C:\> mbr2gpt.exe /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

Determine the partition type & disk number:

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

If Windows PowerShell and Disk Management aren't available, such as when you're using Windows PE, you can determine the partition type at a command prompt with DiskPart >list disk

Conversion example

In the following example:

  1. 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. A DVD-ROM is also present as volume 0.
  2. The OS volume is selected, partitions are listed, and partition details are displayed for the OS partition. The MBR partition type is 07 corresponding to the installable file system (IFS) type.
  3. The MBR2GPT tool is used to convert disk 0. The DiskPart tool displays that disk 0 is now using the GPT format.
  4. 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).
  5. 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.

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.

MBR2GPT example
X:\>DiskPart.exe

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

“Travel for me is all about transformation, and I'm fascinated by those people who really do come back from a trip unrecognizable to themselves and perhaps open to the same possibilities they'd have written off not a month before” ~ Pico Iyer

Related commands

YouTube walkthrough - Convert BIOS / MBR to UEFI / GPT without reformatting - MBR2GPT tool.


 
Copyright © 1999-2024 SS64.com
Some rights reserved