EFI doesn't use the boot sector of the disk. Thus, I suspect that you misunderstand what's happening to your system. My guess is that you're actually damaging the NVRAM entries that hold the boot order for the device. The easiest way to deal with this problem is to not use those entries, and instead name your EFI boot loader EFI/BOOT/bootx64.efi
(or more generally, boot{arch}.efi
, where {arch}
is an architecture code; x64
is the architecture code for x86-64). If you don't want to do this for some reason, and if your EFI shell is a version 2 shell, you can use the bcfg
command in an EFI shell script to do the job. This command is documented to varying extents in various places, such as the Arch Linux wiki and Intel's site. Unfortunately, the older version 1 EFI shell doesn't support the bcfg
command, so this option won't work with it, although it might be possible to extract the relevant code from the TianoCore source code and create a standalone bcfg
command that you could use with an older shell.
If you really need to write to the MBR, then writing an EFI application in C might be a better choice than trying to do it in the EFI shell. There's a lot of EFI programming documentation out there, but most of it is like Unix man pages -- it assumes that you already know the topic and just need to check the details. I've written a brief tutorial introduction, but it's very basic and doesn't cover disk I/O. (You could use that and the source code to gptsync
, which is included in the last couple versions of rEFInd, though, to learn how to read and write the MBR of a disk.)
If I understand correctly, whatever you do (unless using the fallback filename is sufficient), you'd need to fit it into the normal boot sequence. This would be possible with either an EFI shell program launched as the default or as a binary program; but you'll have to be sure that your custom program concludes by launching the "real" boot loader, or that the "real" boot loader launches after the new program.
Simple rules for installation and booting:
a) Windows can boot only BIOS way from MBR style disk
(using MBR record + partition boot record + boot manager on active partition).
b) Windows can boot only UEFI way from GPT style disk
(here boot manager is on EFI System partition).
c) Linux/GRUB can boot BIOS way from MBR style disk.
d) Linux/GRUB can boot either BIOS way or UEFI way from GPT disk
(when booting BIOS way from GPT disk Linux/GRUB uses a special separate boot partition).
Now you can make combinations when dual-booting Windows and Linux.
If you have UEFI firmware it is best to install both Linux and Windows to a GPT disk (disk can be formated/styled to GPT using Linux tools or Windows tools) and boot both systems the UEFI way.
There are even disk tools which can transform an MBR styled disk to GPT styled disk keeping current partition contents (e.g. OS installations)! Transforming GPT to MBR is not possible in general.
Only rewriting boot manager/loader to UEFI would be enough (after MBR to GPT disk transformation) to boot the OS (Windows or Linux) - no need to reinstall (eventually creating additionally EFI System and MS Reserved partitions on disk if missing after transformation).
Note:
If you want to install UEFI way - you boot installation media (DVD/USB) the UEFI way! (Obviously this can be done only if UEFI firmware present on computer.)
Best Answer
BIOS boots by reading the first sector on a hard disk and executing it; this boot sector in turn locates and runs additional code. The BIOS system is very limiting because of space constraints and because BIOS runs 16-bit code, whereas modern computers use 32-bit or 64-bit CPUs. By contrast, EFI (or UEFI, which is just EFI 2.x) boots by loading EFI program files (with
.efi
filename extensions) from a partition on the hard disk, known as the EFI System Partition (ESP). These EFI boot loader programs can take advantage of EFI boot services for things like reading files from the hard disk.As a practical matter, if you're using an OS like Linux that has complex BIOS-mode boot loaders, EFI-mode booting is likely to be similar to BIOS-mode booting, since GRUB 2 (the most popular BIOS-mode boot loader for Linux) has been ported to work under EFI, and many Linux distributions install GRUB 2 by default on EFI systems. OTOH, you can replace or supplement GRUB 2 with other EFI boot loaders. Indeed, the Linux kernel itself can be an EFI boot loader; code was added to do this with the 3.3.0 kernel. Used in this way, the EFI itself loads and runs the Linux kernel, or you can use a third-party boot manager like rEFInd or gummiboot to let you select which OS or kernel to boot.
As Root says, there are clues in the firmware's user interface; however, those are unreliable and vary from one computer to another. The only way to be sure is to check to see how the computer booted. In Linux, for instance, the presence of a directory called
/sys/firmware/efi
is diagnostic. If it's present, you've booted in EFI mode; if it's not present, you've probably booted in BIOS mode. (This directory can be absent on an EFI-mode boot under some circumstances, though.)dmesg
output that refers to EFI is also diagnostic of an EFI-mode boot. In Windows, the partition table of the boot disk is diagnostic; if it's GPT, you booted in EFI mode, and if it's MBR, you booted in BIOS mode.EFI can be faster, but that's not certain. The biggest speed difference is in hardware initialization early in the process. On my systems, this is a fraction of the total boot time, so a reduction in the hardware initialization time, while good, doesn't make all that much difference. It's not like I'm rebooting every ten minutes, after all.
UEFI supports a feature called Secure Boot that's intended, as the name suggests, to improve security. It does this by requiring a digital "signature" of boot loaders, which in turn should require signing of kernels, and so on up the chain. This should make it harder for malware authors to insert their code into the pre-boot process, thus improving security. This sounds good, but it also complicates dual-boot configurations, since code like GRUB and the Linux kernel must be signed. The major Linux distribution vendors are working on ways to make these requirements less of a burden for average Linux users, and they've got some preliminary stuff ready. At the moment, though, disabling Secure Boot is the easiest way to deal with it. This is a practical concern mainly for brand-new computers that ship with Windows 8, since Microsoft is requiring Secure Boot be enabled to get Windows 8 certification. Some people confuse UEFI and Secure Boot (the latter is just one feature of the former), but it deserves mention as a difference between BIOS and UEFI because it's causing some problems for new Windows 8 computers. If you've got an older system or are comfortable enough with firmware setup utilities to disable Secure Boot, this need not be a real problem.
Microsoft ties the boot disk's partition table type to the firmware type (MBR to BIOS; GPT to UEFI). Because MBR tops out at 2TiB (assuming standard sector sizes), this means that UEFI is a practical necessity to boot Windows on over-2TiB disks. You can still use such big disks as data disks under Windows, though, and you can boot some non-Microsoft OSes (such as Linux and FreeBSD) on big disks using GPT under BIOS.
As a practical matter if you're concerned about or interested in UEFI, the biggest issue is simply that UEFI is new enough that support for it is a bit spotty, particularly in some older and more exotic OSes. UEFI itself is new enough that most of its implementations are buggy, and those that aren't vary enough amongst themselves that it can be hard to describe things generally. Thus, using UEFI can be a challenge. OTOH, UEFI is the future. It's got some modest advantages, some of which will become more important in time (such as the 2TiB boot disk limit of Windows). Switching to a UEFI boot will change a few details of the boot process, but your overall computing experience won't change all that much once you overcome any boot issues you may encounter.
EDIT:
Many plug-in cards provide firmware that interfaces with the firmware on the motherboard. The two types of firmware must be able to "talk" if the card's firmware is to do any good. This is necessary to use the card before an OS boots -- for instance, to display your firmware's options or a boot manager menu on a video card, to perform a network boot via a network card, or to boot from a hard disk connected to a disk controller card.
Just as with boot loaders, the code in a plug-in device's firmware is written to interface with either BIOS or EFI (although plug-in cards can support both, if I'm not mistaken). Some EFIs provide options to enable or disable this support on a fine-grained basis, as you've observed. In some cases, an EFI can use a card's BIOS-mode support to enable it to work in EFI mode, by "translating" the calls. (This is common with video cards, for instance; you can often plug in an old video card with nothing but BIOS support in its firmware and still use it to boot in EFI mode.)
I don't know precisely what each of the settings you note does. For instance, I don't know if "BIOS only" for one of these options would make the card work only in BIOS mode, "translate" so that the EFI can use the BIOS-mode calls in EFI mode, or something else. In fact, given the lack of standards in other EFI user interface areas, I would expect the details to differ from one EFI to another, so you may need to consult your computer's documentation or experiment if you need to know the details. I've seen some computers with very similar-sounding options in two different menus, which further complicates matters.