2020年10月13日 星期二

UEFI and BIOS

UEFI and BIOS


UEFI stands for Unified Extensible Firmware Interface and BIOS stands for Basic Input/Output System.

Both UEFI and BIOS are low-level software that starts when you boot your PC before booting your operating system, but UEFI is a more modern solution, supporting larger hard drives, faster boot times, more security features, and—conveniently—graphics and mouse cursors.

How does a computer boot?

You press the power button on your laptop/desktop.

The CPU starts up, but needs some instructions to work on.

The firmware (UEFI or BIOS) launches a Power On Self Test (POST), initializes the hardware, detects the connected peripherals (mouse, keyboard, pendrive etc.) and checks if all connected devices are healthy. If successful, a 'beep' will be heard.

Finally, the firmware code cycles through all storage devices and looks for a boot-loader (usually located in first sector of a disk). If the boot-loader is found, then the firmware hands over control of the computer to it.

So now that the boot-loader is loaded, its job is to load the rest of the operating system. GRUB is one such boot-loader that is capable of loading unix-like operating systems and is also able to chain-load Windows OS. Boot-loader is only available in the first sector of a disk, which is 512 bytes. Given the complexity of modern operating systems, some of these boot-loaders tend to do multi-stage loading, where the main boot-loader loads the second-stage-boot-loader in an environment which is not restricted to 512 bytes.

The boot-loader then loads the kernel into memory. Linux operating systems will run the init process (the master process, from which other processes are forked/executed) and finally initialize the run-levels.

Whereas in Windows, wininit.exe is loaded along with some other processes like services.exe for service control, lsass.exe for local security and authority (similar to run-levels) and lsm.exe for local session management.

After all this, and after some other drivers are initialized, the Graphical User Inferface (GUI) will be loaded and you will be presented with the login screen.



BIOS is stored on an EPROM (Erasable Programmable Read-Only Memory), allowing the manufacturer to push out updates easily. It provides many helper functions that allow reading boot sectors of attached storage and printing things on screen. You can access BIOS during the initial phases of the boot procedure by pressing del, F2 or F10.

UEFI does the same job as a BIOS, but with one basic difference: it stores all data about initialization and startup in an .efi file, instead of storing it on the firmware. This .efi file is stored on a special partition called EFI System Partition (ESP) on the hard disk. This ESP partition also contains the bootloader.

UEFI was designed to overcome many limitations of the old BIOS, including:

UEFI supports drive sizes upto 9 zettabytes, whereas BIOS only supports 2.2 terabytes.

UEFI provides faster boot time.

UEFI has discrete driver support, while BIOS has drive support stored in its ROM, so updating BIOS firmware is a bit difficult.

UEFI offers security like "Secure Boot", which prevents the computer from booting from unauthorized/unsigned applications. This helps in preventing rootkits, but also hampers dual-booting, as it treats other OS as unsigned applications.

UEFI runs in 32bit or 64bit mode, whereas BIOS runs in 16bit mode. So UEFI is able to provide a GUI (navigation with mouse) as opposed to BIOS which allows navigation only using the keyboard.


You might not need UEFI

Though all modern computers come equipped with UEFI by default, some reasons why you might choose BIOS over UEFI are:

If you're beginner and don't care about messing with any type of firmware, BIOS is for you.

If you have < 2 TB per hard disk or partition, you can go with BIOS.

BIOS allows running multiple operating systems without changing any settings This can be a security issue from a modern standpoint, but hey, no hassles for the user.

BIOS provides system information to the operating system. So if your OS runs in 16 bit mode, it does not require writing code for interacting with hardware. It can directly use methods provided by BIOS. Else if the OS switches over to 32bit or 64bit mode, then it needs to provide its own subroutines for interacting with hardware.

If you are someone who prefers a keyboard and text based UI over navigation with a mouse and GUI, then BIOS is for you.


UEFI takes these limitations into account and provides a Legacy mode. In it you can run everything as if you had a BIOS firmware. But keep in mind that Intel has announced that it won't support traditional BIOS from 2020.

The traditional BIOS still has serious limitations. It can only boot from drives of 2.1 TB or less. 3 TB drives are now common, and a computer with a BIOS can’t boot from them. That limitation is due to the way the BIOS’s Master Boot Record system works.

The BIOS must run in 16-bit processor mode, and only has 1 MB of space to execute in. It has trouble initializing multiple hardware devices at once, which leads to a slower boot process when initializing all the hardware interfaces and devices on a modern PC.

The BIOS has needed replacement for a long time. Intel started work on the Extensible Firmware Interface (EFI) specification back in 1998. Apple chose EFI when it switched to the Intel architecture on its Macs in 2006, but other PC manufacturers didn’t follow. In 2007, Intel, AMD, Microsoft, and PC manufacturers agreed on a new Unified Extensible Firmware Interface (UEFI) specification. This is an industry-wide standard managed by the Unified Extended Firmware Interface Forum, and isn’t solely driven by Intel. UEFI support was introduced to Windows with Windows Vista Service Pack 1 and Windows 7. The vast majority of computers you can buy today now use UEFI rather than a traditional BIOS.


How UEFI Replaces and Improves on the BIOS

There’s no way to switch from BIOS to UEFI on an existing PC. You need to buy new hardware that supports and includes UEFI, as most new computers do. Most UEFI implementations provide BIOS emulation so you can choose to install and boot old operating systems that expect a BIOS instead of UEFI, so they’re backwards compatible.

This new standard avoids the limitations of the BIOS. The UEFI firmware can boot from drives of 2.2 TB or larger—in fact, the theoretical limit is 9.4 zettabytes. That’s roughly three times the estimated size of all the data on the Internet. That’s because UEFI uses the GPT partitioning scheme instead of MBR. It also boots in a more standardized way, launching EFI executables rather than running code from a drive’s master boot record.

UEFI can run in 32-bit or 64-bit mode and has more addressable address space than BIOS, which means your boot process is faster. It also means that UEFI setup screens can be slicker than BIOS settings screens, including graphics and mouse cursor support. However, this isn’t mandatory. Many PCs still ship with text-mode UEFI settings interfaces that look and work like an old BIOS setup screen.

UEFI is packed with other features. It supports Secure Boot, which means the operating system can be checked for validity to ensure no malware has tampered with the boot process. It can support networking features right in the UEFI firmware itself, which can aid in remote troubleshooting and configuration. With a traditional BIOS, you have to be sitting in front of a physical computer to configure it.

It’s not just a BIOS replacement, either. UEFI is essentially a tiny operating system that runs on top of the PC’s firmware, and it can do a lot more than a BIOS. It may be stored in flash memory on the motherboard, or it may be loaded from a hard drive or network share at boot.

Different PCs with UEFI will have different interfaces and features. It’s all up to your PC manufacturer, but the basics will be the same on each PC.


How to Access UEFI Settings on Modern PCs

If you’re a normal PC user, switching to a computer with UEFI won’t be a noticeable change. Your new computer will boot up and shut down faster than it would have with a BIOS, and you can use drives of 2.2 TB or more in size.

If you need to access low-level settings, there may be a slight difference. You may need to access the UEFI settings screen through the Windows boot options menu rather than pressing a key while your computer starts. With PCs now booting so quickly, PC manufacturers don’t want to slow down the boot process by waiting to see if you press a key. However, we’ve also seen PCs with UEFI that allow you to access the BIOS in the same way, by pressing a key during the boot-up process.

While UEFI is a big upgrade, it’s largely in the background. Most PC users will never notice—or need to care—that their new PCs use UEFI instead of a traditional BIOS. They’ll just work better and support more modern hardware and features.