Create EFI Bios Grub Partition Loader in Linux

creating-efi-partition Creating EFI Bios Grub Partition in Linux

What is GRUB? 

GRUB is a Multiboot, which provides a user the choice to boot one of multiple operating systems installed on a computer or select a specific kernel configuration available on a particular operating system's partitions.


What is EFI? 

The EFI (Extensible Firmware Interface) system partition or ESP is a partition on a data storage device (usually a hard disk drive or solid-state drive) that is used by computers adhering to the Unified Extensible Firmware Interface (UEFI). When a computer is booted, UEFI firmware loads files stored on the ESP to start installed operating systems and various utilities.


Requirements 

Make sure you've enabled EFI in your BIOS.

Also make sure you have all the package requirements such as parted and gparted


Resizing Partition for EFI 

Scenario is, we don't have an EFI partition and we require one for EFI to work. Below is a partition without an EFI partition, so we need to create it.

Number Start End Size File system Name Flags
1 1049kB 100GB 100GB ext2
3 101GB 5987GB 5887GB ext4
2 5998GB 6001GB 2999MB linux-swap(v1)

Partition 1 is ext2 which is the /boot mount, the partition 3 is the /  root partition.  The 2 partition is our swap but we need another partition which holds our EFI. In order to do this we need gparted ISO live CD/DVD on a CD/DVD or USB stick.  You can't change a partition if it's mounted.

No EFI Partition Yet

Creating a Partition for EFI 

Since we don't have a partition set, we need to resize to create space from the main partition.  I'm going to resize the 5.36 partition with an unallocated partition of 10GB since I'll be using the EFI partition a lot.  Load parted or Gparted and make the changes.  Changes can take a while and if you have an encrypted file system you might be out of luck unless you created some extra unallocated space.


The changes should look like the below after you're done.

After the changes of partition is completed I restarted the system.  Since we created the partition at the end our drives haven't changed otherwise we would need to change UUID's, etc.


After the reboot, load parted in a terminal. Format the partition as ext4, our partition is # 4

In parted in a terminal we can now create the boot flags for EFI.

Number Start End Size File system Name Flags
1 1049kB 100GB 100GB ext2
3 101GB 5987GB 5886GB ext4
4 5987GB 5998GB 10.7GB
2 5998GB 6001GB 2999MB linux-swap(v1)

 From parted command prompt we want to set the GPT partition table to flag as bios_grub, we do this by typing the below command inside of parted command prompt.

Now let's list the changes to our 4 partition.

Model: ATA WDC WD6002FZWX-0 (scsi)
Disk /dev/sde: 6001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 100GB 100GB ext2
3 101GB 5987GB 5886GB ext4
4 5987GB 5998GB 10.7GB bios_grub
2 5998GB 6001GB 2999MB linux-swap(v1)

Highlighted text in red shows our changes.


Quit from parted.

Now we can install the Grub requirements on the newly created partition.

Output should show the below.

Installing for i386-pc platform.
Installation finished. No error reported.


If required reinstall the grub-efi package on the system.


Reinstalling grub-efi 

Then run the grub-install like we did above again.


Updating Grub

OR if you're using grub2, use below command.


Font size: +
Report Print
 

By accepting you will be accessing a service provided by a third-party external to https://www.klokur.com/