Sunday, November 24, 2013

Convert MBR to UEFI(GPT) and Enable Secure Boot

Understanding the Limitations of MBR scheme:

The Master Boot Record (MBR) partitioning scheme is legacy partitioning scheme that is used by most operating systems. The MBR itself resides entirely on the first sector (512 bytes) of a hard disk. Of that space, the first 440 bytes of the MBR are devoted to the boot loader. The BIOS reads this code and executes it when the computer boots. This code area is followed by data space used to store information about the four partitions, known as Primary partitions. Each partition is described in two ways: using cylinder/head/sector (CHS) notation and using logical block addressing (LBA) notation. The CHS notation is obsolete because of its 24-bit limit which can only address 8GB of disk space. The 32-bit LBA values permits us to address up to 2TB. Because we don’t have any space left in the MBR to increase LBA size; this caps MBR access at only 2TB of disk space.

The other disadvantage of MBR is that the total data storage space of a computer hard disk can be divided into at most four partitions. If we need to have more than four partitions on a hard disk then we need to create a special type of partition called an extended partition. These partitions have data-integrity problems since they are a single data structure that's vulnerable to damage caused by carelessness or hardware failure. Additionally the extended partition data structure doesn’t have any form of error-detection capability, so damage can be difficult to spot.

The GUID Partition Table (GPT) is a new standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the PC BIOS. GPT uses the 64 bit disk pointers, which allow for a maximum disk partition size of 9.4 Zeta bytes, or 9.4 billion Tera Bytes.

Another benefit of using GPT based disks includes overcoming the 4 primary partition limit of a MBR disk. GPT supports a maximum of 128 primary partitions. GPT data structures are also well defined and stored twice on the disk: once at the start and again at the end. This improves the odds of successful data recovery resulting from damage caused by an accident or a bad sector. Also, cyclic redundancy check (CRC) values are computed for critical data structures, improving the odds of detecting of data corruption. The figure below shows the layout of a GPT disk and how the data structure is stored.

Not all Windows OSes provide full support for GPT disks. From Windows Server 2003 SP1 onwards, GPT disks can be used as data disks but not as the boot disk. From Windows Server 2008 onwards, only x64 versions of the Microsoft OS support GPT disks as the boot disk in EFI (Extensible Firmware Interface) boot mode. GPT disks are not supported as the boot disk in BIOS Mode when booting to Windows OSes.

Converting Windows BIOS installation to UEFI


  1. Create a system repair disc (  ). You can skip this step if you have a Windows installation media. Is a good measure to reboot and verify you can start your system from this disc.
  2. Identify which disk you want to convert (usually is #0). This can be done by looking at the number in the Windows Disk Management.
  3. Download gptgen from here  . This tool will allow you to convert your MBR disc to GPT with the data included.
  4. ATTENTION: After this step, you won't be able to boot into Windows the whole process is completed.There is no turning back!
    Unzip gptgen and then run CMD with elevated privileges. (replace the 0 with the identified disk number).
    This *will* result in a BSOD shortly after and it's to be expected:
      gptgen.exe -w \\.\physicaldrive0
  5. Boot using your Windows installation or previously generated system repair disc.
  6. Choose language and preferences, and then select Repair Your Computer -> Troubleshoot -> Advanced options ->Command Prompt
  7. We will need the disk partitioning tool. With this, we will recreate the boot partitions. Type:
  8. Identify the boot disk where Windows is located, typing:
      list disk
     Something like this should appear:
          Disk ###  Status         Size     Free     Dyn  Gpt
          --------  -------------  -------  -------  ---  ---
        * Disk 0    Online          128 GB      0 B        *
  9. Once identified, select the disk (replace with the correct number):
      select disk 0
  10. Verify the partitions:
      list partition
  11. Something similar at the info below should appear.
           Partition ###  Type              Size     Offset
           -------------  ----------------  -------  -------
           Partition 1    Primary            350 MB  1024 KB
           Partition 2    Primary            126 GB   350 MB
  12. Delete the previous system partition:
      select partition 1
      delete partition
  13. Create the new boot partition, Microsoft reserved partition:
      create partition EFI size=100 offset=1
      format quick fs=fat32 label="System"
      assign letter=S
      create partition msr size=128 offset=103424
  14. If you list the partitions again, you should have ended up with something like this:
           Partition ###  Type              Size     Offset
           -------------  ----------------  -------  -------
           Partition 1    System             100 MB  1024 KB
           Partition 2    Reserved           128 MB   101 MB
           Partition 3    Primary            126 GB   229 MB
  15. Ensure that your Windows installation is mounted, replacing 3 with the volume number of the Windows installation (usually 1):
      list volume
      select volume 3
      assign letter=C
  16. Exit diskpart:
  17. Generate boot partition data, replacing C: with the letter of the Windows installation (usually C:):
      bcdboot c:\windows /s s: /f UEFI
  18. Cross your fingers and then restart your computer!
Easy way (Fresh Windows Installation):
1.       Take a clean disk (delete all partition if exists)
2.       Set BIOS to UEFI boot
3.       Boot with Win8.1 Install ISO, Select the unallocated space and click next. Windows detects that the PC was booted into UEFI mode, and reformats the drive using the GPT drive format, and begins the installation

Secure boot

No comments: