Convert from EFI to BIOS boot mode

26,097

Solution 1

I figured out the exact way by myself. Rod Smith was right, it’s easier than I thought.

Here the solution if anybody else needs it:

Original Partition Layout:

  • /dev/sda1 (EFI Partition)
  • /dev/sda2 (Boot Partition)
  • /dev/sda3 (LVM2/LUKS encrypted Root & Swap)

Converting to BIOS boot:

  1. I deleted the EFI Partition and created a new partition with the bios_grub flag instead of it.
  2. Using this tutorial I mounted the encrypted file system, chrooted into it and installed GRUB.
  3. Remove the EFI Partition from /etc/fstab.

Solution 2

It's possible and it's easier than you think. Linux can boot fine from a GPT disk in BIOS mode, so there's no need to do the MBR-to-GPT conversion. With any luck, all you'll need to do is to install a BIOS-mode boot loader (GRUB, LILO, or SYSLINUX) to the disk. There are three caveats, though:

  • I've never used LUKS, so I'm not sure how this would affect things. I wouldn't expect any problems, but that might be my lack of experience talking.
  • Some EFIs have quirky requirements for booting in BIOS mode. Most commonly, some will only boot in BIOS mode if they see a boot/active flag on an MBR partition, and this is normally absent on GPT disks. You can work around this by using an old version of fdisk (one that lacks GPT support, which was added only very recently) to set the boot/active flag or by using a new version of parted to set a flag (whose name I don't recall offhand) on the whole disk. If you're lucky you won't need to deal with this issue. See this page for more on this problem.
  • If the computer is dual-booting with Windows, converting it to boot in BIOS mode is likely to be much trickier. In this case, it might be easier to install rEFInd as a boot manager. rEFInd can then boot Windows in EFI mode and boot the BIOS-mode GRUB (or whatever you end up using). To do so, though, you'll need to edit refind.conf: Uncomment the scanfor line and ensure that hdbios is among the items that are scanned.

Solution 3

Converting Ubuntu into Legacy mode

Note: Use this procedure only to convert an UEFI mode Ubuntu installation to boot in BIOS/CSM/legacy mode. Such a conversion may be necessary if some hardware doesn't work correctly under UEFI mode. (Graphics cards are a common source of problems.) Converting to boot in BIOS/CSM/legacy mode while Windows boots in UEFI mode can make the boot process more awkward -- you'll need to use the computer's built-in boot manager to switch between OSs, and some computer's have such poor boot managers that this may be impossible.

  • If Ubuntu is installed on a GPT disk (you can check it via the sudo parted -l command), use GParted partition editor to create a BIOS-Boot partition (1MB, unformatted filesystem, bios_grub flag) at the start of its disk.
  • Start Boot-Repair, and select Advanced options -> GRUB location tab.
  • Uncheck the Separate /boot/efi partition option

    Uncheck the Separate /boot/efi partition option

  • Click the Apply button in the lower right corner.

  • Set up your BIOS so that it boots the HDD in Legacy mode. Generally this setting is located in the Boot tab → Boot order section of the BIOS.

Source: revised from: UEFI - Community Help Wiki

Solution 4

I know this is old (sorry for necro) but I found no guide out there that actually work for my Ubuntu 16.04, and I struggled with @Lukas S's answer, as well as with the official Ubuntu UEFI to BIOS guide (@karel's answer). Posting it here rather than editing the Ubuntu wiki guide as this askubuntu question pops up earlier in all search engines.

In fact, I'm surprised either of those 3 guides can actually work for anyone as-is because UEFI systems do not (typically) have the grub-i386-pc files needed for grub-install to work, so they fail at that step. Boot-repair also fails when trying to repair (saying "grub-pc cancelled"). Probably the authors of these guides had those files somehow, maybe from previous struggles.

My setup was a typical EFI system, which is actually an old Ubuntu 16.04:

  • /dev/sda1=fat32 (esp,efi) partition
  • /dev/sda2=Linux system
  • /dev/sda3=swap (unimportant, you don't have to have this)
  • the Linux system on sda2 lacks the /usr/lib/grub/i386-pc folder which has the modules needed for BIOS boot and grub-install

My disk is also GPT, and this is perfectly fine - no need to convert gpt to msdos.

Steps that I had to do to successfully convert from UEFI to BIOS:

  • delete the sda1 partition

  • recreate one which is unformatted but with the bios_grub flag. Note: Gparted is iffy, in that when I chose "unformatted" when creating it, it gave me a fat32 one (which grub-install doesn't like). I had to right-click "format to" and chose "cleared", then applied, then added the "bios_grub" flag.

  • boot in BIOS mode (important!) from a Ubuntu live CD. I used Xubuntu 20.04.3. It's important to boot in BIOS mode because that will give you the grub-i386-pc files you need later.

  • mkdir /mnt/sda2

  • mount /dev/sda2 /mnt/sda2

  • for f in sys dev proc; do mount -o bind /$f /mnt/sda2/$f; done

  • rsync -a /usr/lib/grub/i386-pc /mnt/sda2/usr/lib/grub/ (important! no / after i386-pc)

  • chroot /mnt/sda2 /bin/bash

  • grub-install /dev/sda

Done. Rebooted and the system now boots in BIOS mode from the hard drive.

My 16.04 now has newer grub-pc-i386 files in /usr/lib/grub, but it's not bothered. It's encouraging to know this procedure work cross distribution versions. I plan to upgrade to 20.04 anyway.

p.s. Someone should probably also edit the the official Ubuntu wiki ...

Share:
26,097

Related videos on Youtube

Lukas F.
Author by

Lukas F.

Updated on September 18, 2022

Comments

  • Lukas F.
    Lukas F. over 1 year

    I have a Samsung Notebook NP900X4C with an LUKS encrypted installation on it. The system is booting in UEFI mode.

    The problem is that the samsung-notebook kernel module is disabled in UEFI mode and due to that I am missing features like the keyboard backlight.

    Is it possible to modify the current installation so it can boot in BIOS mode?

    Is this correct that the basic steps would be converting the disk from GPT to MBR and installing grub from a live CD? Would this be possible with a LUKS partition?