Thursday, March 2, 2017

BIOS vs UEFI - What is the Difference

Basic Input-Output System Vs. Unified Extensible Firmware Interface

Introduction:

Basic Input-Output System (BIOS) and Unified Extensible Firmware Interface (UEFI) are two firmware interfaces for computers that work as an interpreter between the operating system and the computer firmware. Both of these interfaces are used at the startup of the computer to initialize the hardware components and start the operating system which is stored on the hard drive.



Role wise both are the same. The older one is now called Legacy BIOS and the newer version is called UEFI.


BIOS:

BIOS works by reading the first sector of the hard drive (MBR) which has the next device’s address to initialize or code to execute. BIOS also selects the boot device that needs to be initialized for starting the operating system. Since BIOS has been in use since the very beginning (since 1975), it still works in 16-bit mode, limiting the amount of code that can be read and executed from the firmware ROM.

UEFI:

UEFI does the same task a little differently. It stores all the information about initialization and startup in a .efi file instead of the firmware. This file is stored on the hard drive inside a special partition called EFI System Partition (ESP). The ESP partition will also contain the boot loader programs for the Operating System installed on the computer. UEFI is meant to completely replace BIOS in the future and bring in many new features and enhancements that can’t be implemented through BIOS.

Some of those features are discussed below:

(1) Breaking out of size limitations:

BIOS uses the Master Boot Record (MBR) to save information about the hard drive data while UEFI uses the GUID partition table (GPT). The major difference between the two is that MBR uses 32-bit entries in its table which limits the total physical partitions to only 4. Each partition can only be a maximum of 2TB in size, while GPT uses 64-bit entries in its table which dramatically extends the support for size possibilities of the hard drive up to Zeta Byte and maximum 128 partitions. (Read more on the difference between MBR and GPT in my next blog article).

(2) Speed and performance:

Since UEFI is platform-independent, it may be able to enhance the boot time and speed of the computer. This is especially the case when you have large hard drives installed on your computer. This enhancement depends upon how UEFI is configured to run. UEFI can perform better while initializing hardware devices. Normally this speed enhancement is a fraction of the total boot time, so you will not see a huge difference in overall boot time. Developers can make use of the UEFI shell environment which can execute a command from other UEFI apps optimizing the performance of the system further.

(3) Security

'Secure boot' is a feature of UEFI that has been implemented in Windows 8 recently. The biggest benefit of UEFI is its security over BIOS. UEFI can allow only authentic drivers and services to load at boot time, making sure that no malware can be loaded at computer startup. Microsoft implemented this feature to counter-piracy issues in Windows, while Mac has been using UEFI for quite some time now. Secure Boot works by requiring a digital signature of boot loaders which should require a digital signature by the Kernel. This process continues until the operating system is completely started. This secure boot feature is also one of the reasons why it is more difficult to install another operating system on a Windows machine.







(4) Backward Compatibility using the Compatibility Support Module (CSM):


For backward compatibility, most of the UEFI implementations on PC-class machines also support booting in legacy BIOS mode from MBR-partitioned disks, through the Compatibility Support Module (CSM) which provides legacy BIOS compatibility. In that scenario, booting is performed in the same way as on legacy BIOS-based systems, by ignoring the partition table and relying on the content of a boot sector.
BIOS booting from MBR-partitioned disks is commonly called BIOS-MBR, regardless of it being performed on UEFI or legacy BIOS-based systems. As a side note, booting legacy BIOS-based systems from GPT disks is also possible, and it is commonly called BIOS-GPT.
Despite the fact MBR partition tables are required to be fully supported within the UEFI specification, some UEFI firmware immediately switches to the BIOS-based CSM booting depending on the type of boot disk's partition table, thus preventing UEFI booting to be performed from EFI System partitions on MBR-partitioned disks. Such a scheme is commonly called UEFI-MBR.





(5) Network boot support:

UEFI specification includes support for booting over the network through the Preboot eXecution Environment (PXE). Underlying network protocols include Internet Protocol (IPv4 and IPv6), User Datagram Protocol (UDP), Dynamic Host Configuration Protocol (DHCP), and Trivial File Transfer Protocol (TFTP).
Also included support for boot images remotely stored on storage area networks (SANs), with Internet Small Computer System Interface (iSCSI) and Fibre Channel over Ethernet (FCoE) as supported protocols for accessing the SANs.

(6) Boot Manager:

The UEFI specification defines a "boot manager", a firmware policy engine that is in charge of loading the operating system loader and all necessary drivers. The boot configuration is controlled by a set of global NVRAM variables, including boot variables that indicate the paths to the loaders.
Operating system loaders are a class of the UEFI applications. As such, they are stored as files on a file system that can be accessed by the firmware, called EFI System partition (ESP). UEFI defines a specific version of FAT, which encompasses FAT32 file systems on ESPs, and FAT16 and FAT12 on removable media. Supported partition table schemes include MBR and GPT, as well as El Torito volumes on optical disks. UEFI does not rely on a boot sector, although ESP provides space for it as part of the backward compatibility. UEFI booting from GPT disks is commonly called UEFI-GPT.
Boot loaders can also be automatically detected by the UEFI firmware, to enable booting from removable devices. Auto-detection relies on a standardized file path to the operating system loader, depending on the actual architecture to boot. Format of the file path is defined as /BOOT/BOOT.EFI, e.g. /efi/BOOT/BOOTX64.EFI

Technical differences between the two:



Friday, February 17, 2017

What is Virtualization?

An overview

In computing, virtualization is a broad term that refers to the abstraction of computer resources. The common theme of all virtualization technologies is the hiding of technical detail, through encapsulation. Examples- JVM, RAID, DFS, Virtual Memory, VMs, VHDs, etc.

Broadly Virtualization is divided into two categories:

(1) Platform virtualization: It involves the simulation of virtual machines, like server virtualization, desktop virtualization, etc. The operating system is abstracted from the hardware and is no longer bound to the architecture of the machine. There are several approaches to achieve platform virtualization-
       (a) Server virtualization
       (b) Client virtualization
       (c) Application virtualization

(2) Resource virtualization: It involves the simulation of combined, fragmented, or simplified resources, like storage virtualization, network virtualization, I/O virtualization, etc.


Server virtualization
Server virtualization makes it possible for the OS of a physical machine (Host) to run on a virtual layer (the Hypervisor*). This allows us to run multiple virtual machines (VMs) on the same physical machine. This physical machine with a virtualization layer is called 'Virtual host' or simply 'Host' and each guest OS running on the host is called Virtual Machines (VMs).

Server virtualization can be achieved by the following techniques:

       (i) Full-virtualization
       (ii) Paravirtualization /OS-Assisted virtualization
       (iii) Hardware-Assisted virtualization

Full virtualization:
  • Does dynamic binary translation/ rewriting
  • Creates emulation layer to emulate hardware
  • Virtual Machine Monitor (Hypervisor) traps and emulates privileged instructions1.
  • Examples- Hyper-V, VMware vSphere, QEMU, BOCHS, etc.
 

Native Privileged Architecture (Without visualization)


Full virtualization

Paravirtualization / OS-Assisted virtualization:
  • Guest OS is modified to process privileged instructions.
  • VMM is no longer required to translate instructions, it is only responsible for handling the virtualization layer.
  • Guest OS uses a specialized API to talk with VMM.
  • Example- Xen

Xen Paravirtualization

VMware Paravirtualization

Hardware-Assisted virtualization:
  • The VMM uses processor extension (Intel-VTx or AMD-V) to intercept and emulate privileged instructions.
  • Guest OS runs at kernel level (Ring 0)2 and VMM runs in a more privileged Ring than the Ring 0.

HW-Assisted virtualization
Intel-VTx HW virtualization

Privileged level /Ring: 


Privilege Ring



*Hypervisor: Hypervisor or Virtual Machine Monitor (VMM) is a software layer that allows several virtual machines to run on a single physical machine. There are two types of hypervisors or VMMs:



(i) Type-1 (Bare-Metal): It runs directly on the given hardware platform. It has complete control over the physical machines. Microsoft Hyper-V, VMWare ESX/ESXi, Citrix XenServer, IBM zVM, etc are type-1 hypervisors.



(ii) Type-2 (Hosted): It runs within an operating system environment. It is loaded on host OS as an application. VMWare Workstation, Microsoft Virtual PC, Sun virtual box, etc are type-2 hypervisors. 









Hyper-V

Microsoft Hyper-V is a type-1 hypervisor with a different implementation. The host OS is called a Parent partition and all VMs are called Child partitions.




A comparison with other type-1 hypervisors: