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.

http://social.technet.microsoft.com/wiki/contents/articles/14286.converting-windows-bios-installation-to-uefi.aspx

Converting Windows BIOS installation to UEFI


Instructions:

  1. Create a system repair disc (http://windows.microsoft.com/en-US/windows7/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 http://sourceforge.net/projects/gptgen  . 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:
      diskpart
  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:
      exit
  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

How to find if your computer supports Intel-VT or AMD-V

Intel and AMD are two of the most prominent PC processor providers in the world. AMD and Intel's virtualization techniques are different and incompatible, but all hypervisors hide the differences from end user. So How do I find out if the processors in my laptop, desktop or server supports resource virtualization? Does my system run on Intel-VT or AMD-V?

Three things that make VT-VTD possible

Chipset Support
Processor Support
BIOS support.

Windows System:
Download Securable
Securable is a very easy to check if you processor has virtualization support, because it requires no installation. All you have to do is run the executable (.exe) file. Right-click the file you have downloaded, and select “Run as administrator.”


Intel and AMD Tools:
AMD Virtualization Compatibility tool
Intel Processor Identification utility
Find your processor name from My computer properties and look these up on the following pages:
AMD Product Central


The Intel site is the most useful, and will tell you directly if the processor supports virtualization (Intel VT-x) and/or secure passthrough of PCI devices to guests (Intel VT-d). The AMD site is less than useful in this respect.


How to find the support on a Linux machine:
Run the following command under Linux:
# egrep ‘(vmx|svm)’ /proc/cpuinfo

If nothing is printed, it means that your CPU does not support hardware virtualization. Otherwise it does – but you still need to make sure that virtualization is enabled in the BIOS. If the SVM flag is returned then your processor supports AMD-V. If the VMX flag is returned then your processor supports INTEL-VT.

Other flags:
ept — Extended Page Tables, an Intel feature to make emulation of guest page tables faster.

vpid — VPID, an Intel feature to make expensive TLB flushes unnecessary when context switching between guests.

npt — AMD Nested Page Tables, similar to EPT.

tpr_shadow and flexpriority — Intel feature that reduces calls into the hypervisor when accessing the Task Priority Register, which helps when running certain types of SMP guests.

vnmi — Intel Virtual NMI feature which helps with certain sorts of interrupt events in guests.