Dual Booting UEFI and BIOS on Linux
Jun 13, 2023

Dual Booting UEFI and BIOS on Linux

There are several reasons why one might choose to set up their computer for dual booting with Unified Extensible Firmware Interface (UEFI) and Basic Input Output System (BIOS). Perhaps you're managing a fleet of computers that have different boot methods, or maybe you have a golden image that you want to deploy in both BIOS and UEFI scenarios. Whatever the case may be, this post is aimed at providing a thorough guide on how to dual boot UEFI and BIOS on Linux.

What are UEFI and BIOS?

Before we delve into the process, let's understand what UEFI and BIOS are:

  • BIOS: The BIOS is the traditional, low-level software that starts when you boot up your computer and kick-starts your operating system.
  • UEFI: UEFI is the modern, feature-rich replacement for BIOS. It includes a number of security enhancements and supports larger hard drives, faster boot times, and more.

Despite UEFI being more advanced and feature-rich, many computers and servers still use the older BIOS system. Hence, the need for a dual booting setup.

Partition Layouts

For the dual booting setup, you'll need two types of partitions: a BIOS bootable partition and an EFI System Partition (ESP).

Here are examples of the partition layouts:

  1. BIOS Bootable Partition
  2. File System: Unformatted
  3. Size: 1 MB
  4. Flags: bios_grub
  5. EFI System Partition (ESP)
  6. File System: FAT32
  7. Size: At least 100 MB, but typically 512 MB
  8. Flags: boot, esp

Below is an example of how the partitions might look:

# fdisk -l /dev/vda
Disk /dev/vda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 8192 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 73DD57AE-5208-48C2-86D0-7216E567DABB

Device       Start      End  Sectors  Size Type
/dev/vda1     2048     4095     2048    1M BIOS boot
/dev/vda2     4096   528383   524288  256M EFI System
/dev/vda3   528384  2166783  1638400  800M Linux filesystem
/dev/vda4  2166784 20969471 18802688    9G Linux filesystem

In this example, /dev/vda1 is the BIOS, and /dev/vda2 is the ESP/EFI bootable partition.

Installation Process

Now that we have the partitions set up, we can proceed to the installation of the GRUB bootloader.

  1. First, install the GRUB bootloader for BIOS by specifying --target=i386-pc:
# grub-install --target=i386-pc /dev/sda

This command installs GRUB to the Master Boot Record (MBR) of the drive.

  1. Next, install GRUB for UEFI. In order to do this, you'll first need to mount your ESP. Assuming the ESP is on /dev/sda1, you could do:
# mount /dev/sda2 /boot/efi

And then install GRUB for UEFI:

sudo grub-install --target=x86_64-efi /dev/sda

Now, GRUB has been installed for both BIOS and UEFI.

  1. Finally, generate the GRUB configuration file:
sudo grub-mkconfig -o /boot/grub/grub.cfg

With this, your Linux system is now ready to boot in either UEFI or BIOS mode.

Conclusion

Dual booting with UEFI and BIOS on Linux can be a versatile solution for environments with a mix of modern and older systems. It might require a bit of initial setup, but the flexibility it provides can be worth the effort,

Related posts

Browse more
We haven't published any posts