Share This Post

A ConfigMgr Geek’s Guide to the MBR2GPT.exe Tool

If you have started a Windows 10 migration in your corporate environment, you’ve probably heard about MBR2GPT.exe, the tool that helps convert the disk layout on a PC from the legacy Master Boot Record (MBR) to GUID Partition Table (GPT). While the tool was introduced in the Insider Preview versions, it is officially supported in Windows 10 1703 (also known as the Creators Update). MBR2GPT.exe is the only Microsoft-supported way to convert a production disk (one with data already on it) from MBR to GPT without data loss. The tool can be run from an administrative command prompt after an in-place upgrade to Windows 10 1703, or in the Windows PE (WinPE) environment. Furthermore, older versions of Windows 10 (v1511 and v1607) can be converted using the tool if booted into WinPE.

If a drive is protected with BitLocker encryption, then you will need to suspend BitLocker before converting. After conversion, delete the existing protectors (PIN, Password, Certificate, etc.) and recreate them to resume encryption. If you are using third-party disk encryption, you need to work with your ISV. It’s the only sure way to determine the minimum requirements to successfully convert disk partitions without triggering a device lock or brick while keeping the drive encrypted.

How Does It Work?

Converting within Windows

To start the conversion within Windows, open an administrative command (or PowerShell) prompt. To see the full list of command line switches that can be passed to the tool, type mbr2gpt.exe /? Or mbr2gpt.exe /help.

mbr2gpt-01

(Tap or click for larger view)

The correct syntax to run the conversion tool within a Windows session is

mbr2gpt.exe /convert /allowFullOS

mbr2gpt-02

(Tap or click for larger view)

If you simply want to validate the disk (run a check without converting), then just replace the /convert switch with /validate.

mbr2gpt.exe /validate /allowFullOS

mbr2gpt-03

(Tap or click for larger view)

Converting within WinPE

To convert disk layout in WinPE, use a Run Command Line action with the following syntax:

cmd.exe /c mbr2gpt.exe /convert /disk:<disknumber>

mbr2gpt-04

(Tap or click for larger view)

What If I’m Refreshing or Replacing the PC?

If you’re re-installing Windows to the current disk, or if you’re replacing the drive or computer, you will not be using the MBR2GPT.exe tool. If the system is booted in UEFI mode before the Format and Partition Disk step happens in the Install Operating System group, the Task Sequence engine will happily format the disk for GPT. If you have created a sequence that restores user data, it will still be able to be restored.

What Are the Limitations?

The first and perhaps most important limitation is that MBR2GPT.exe is not the same thing as “BIOS to UEFI”. MBR2GPT.exe is a tool to convert partition layout while BIOS to UEFI is the process of converting a system’s firmware mode from BIOS to UEFI.

While MBR2GPT.exe can be run from the full OS, or in WinPE, it should be run before the conversion of BIOS to UEFI during an in-place upgrade and most preferably in WinPE. If the tool is run after the firmware mode is converted, and for some reason is unsuccessful with the conversion, the device will essentially be bricked until the PC is manually converted back to BIOS mode.

If you are performing a PC refresh or replace, the PC should be converted before the “Format and Partition Disk” step runs in the Install Operating System Group. It is possible to do this later in the sequence, but this route is more reliable. This is because this group has two Format and Partition actions with variables on them that read whether the PC is in BIOS mode or UEFI mode and formats and partitions the disk accordingly. As you can see below, the top image depicts what the Task Sequence engine will do to the disk if the PC is running in BIOS mode, and the bottom image shows what it will do to the disk if it is in UEFI mode. The most important takeaway is that BIOS mode means the disk will be formatted in MBR layout, and UEFI means it will be formatted in GPT layout.

mbr2gpt-05

(Tap or click for larger view)

mbr2gpt-06

(Tap or click for larger view)

Legacy versions of Windows aren’t officially supported. If you successfully convert the partition type into GPT layout, you’ve stepped out of the realm of support. Typically, “not officially supported” means it can likely be done, but it isn’t well tested internally, so you’re on your own if something goes wrong or if you have questions. It would be better to upgrade the system to a version of Windows that is supported.

Once the disk layout has been converted, you cannot undo it. Furthermore, if the layout was performed during an in-place upgrade, you will not be able to go back to a previous version of Windows. I was able to test and validate this limitation in all three major PC vendors (Dell, Lenovo, HP).

To use the tool, the disk to be converted needs to have less than four partitions (meaning three partitions is the maximum). In testing the conversion tool, it was noted that Dell models create an extra recovery partition during an in-place upgrade, which can cause the conversion tool to fail if you hit the limit of partitions before the upgrade runs. To get around this, I deleted all recovery partitions, leaving the PC with only two partitions. During the in-place upgrade, the Dell PC created a third partition (as expected) that didn’t cause the conversion tool to fail. The HP and Lenovo models I tested did not create extra partitions during the in-place upgrade.

If you are going to use one sequence to handle all hardware models, ensure that you are supplying the correct driver package for the model running the upgrade and that the engine can read and process the variable. If the variable you set on your driver package is incorrect, setup.exe will not use it. While the discussion about why you need to provide driver packages during an in-place upgrade is a bit off topic, it is important to note. It matters because some of the vendor models that I tested failed the MBR2GPT.exe conversion later in the in-place upgrade when I did not also provide driver packages to them. This may not be true for every vendor model, but it happened consistently enough in my testing to be deemed important to take note of.

How Do I Check What Partition Type My Disks Are Using?

Open an administrative command prompt and type the following:

diskpart

select disk <disk number>

list part

sel part <partition number>

detail part

If the disk is using MBR partition type, it will display 07 for the type in the detail part command as pictured below on this Windows 7 PC.

mbr2gpt-07

(Tap or click for larger view)

diskpart

list disk

Any disk with an asterisk under GPT in the table is in GPT layout as pictured on this Windows 10 PC.

mbr2gpt-08

(Tap or click for larger view)

Troubleshooting

When the MBR2GPT.exe tool is run, it creates four logs in the %windir% directory (C:\Windows). The four logs are setuperr.log, setupact.log, diagerr.xml, and diagwrn.xml with setuperr.log having the most detailed information. In the example below, I ran the tool and saw in setuperr.log that it failed because there are too many partitions.

mbr2gpt-09

(Tap or click for larger view)

A full list of error codes for the tool can be found on TechNet under the Return Codes section here docs.microsoft.com. Note that these error codes are specific to the tool itself and shouldn’t be confused with error codes that the Windows 10 setup or the Task Sequence engine may throw.

Real-World Applications

If you would like readymade sequences that handle both MBR2GPT.exe and BIOS to UEFI for both PC refresh/replace and in-place upgrade scenarios, I have created a document that walks through the setup of both scenarios on Adaptiva’s SCCM Academy. The community solution is free, and includes two Task Sequences that can be imported into your environment. It’s up to you to provide all the dependencies (1703 Boot Image, Vendor Tools for BIOS to UEFI, etc.). However, these are working sequences that I have run against all three vendors in my lab, and they could save you days of works.

You can download the Secure 10: BIOS to UEFI 2017 Update Document and Task Sequences from: http://www2.adaptiva.com/l/139131/2016-07-18/j7lfk.

Happy migrating!

https://drive.google.com/file/d/0B9QRmfO509o6WFF2WXdfd2xTOWs/view

resources-ami-castoAmi Casto is the technical evangelist for Adaptiva. If you have questions or problems using these task sequences, tweet her at @adaptivaami.

Share This Post

Founded in 2004 by the lead architect of Microsoft SMS 2003, Adaptiva has grown into one of the premier providers of IT systems management solutions. Adaptiva solutions leverage existing IT resources to enhance the operation of Microsoft System Center Configuration Manager (SCCM) without disrupting service to end-users. Adaptiva has sold over 3,000,000 seats of software deployed in more than 100 countries. A Microsoft Gold Partner, Adaptiva conquers the complexity of IT by streamlining operations, extending the functionality of Microsoft System Center Configuration Manager (SCCM) and rapidly improving ROI on existing systems. Adaptiva provides easy to use software that seamlessly integrates with Microsoft SCCM to help you better manage your IT while reducing the total cost of ownership.

Leave a Reply