Set bios_grub flag to partition

34,581

Solution 1

Your problem is with the Compatibility Support Module (CSM), which is enabled on your computer. Many Linux installation instructions suggest enabling the CSM, but this is bad advice. (The page you referenced comments that legacy mode will do nothing good, but doesn't really emphasize this point.) If you disable your CSM (aka "legacy boot support" or something similar) in your firmware setup utility, you should be able to get the Ubuntu installer to boot in EFI mode, which should then enable Boot Repair to work correctly. (In some cases, there are no "CSM" or "legacy boot" options, but there is a "boot mode" option with settings like "UEFI only," "UEFI or legacy," or "legacy only." Setting this to "UEFI only" should disable the CSM.)

If you can't find the appropriate options, I recommend you try using my rEFInd boot manager to force an EFI-mode boot. This is an EFI-only boot manager; if it boots, you can be sure you've booted in EFI mode, and on a UEFI-based PC, if it shows you an Ubuntu boot option, using it will boot in EFI mode. The page to which I linked includes download links for USB flash drive and CD-R versions of rEFInd; use one of those to prepare a bootable medium and boot to it. If this works and enables you to boot to Ubuntu, you can then either run Boot Repair or install rEFInd using its PPA or Debian package, which will bypass GRUB and use rEFInd as the default boot manager. One caveat, though, is that the downloadable USB flash drive and CD-R versions of rEFInd do not support Secure Boot. If this feature is enabled, you must either disable Secure Boot or jump through extra hoops to get rEFInd working with Secure Boot. The former will be easier than the latter.

Solution 2

assuming that grub installed successfully, but you are getting the windows loader. do this:

1) make grub the default boot loader:

boot into a live CD and try ubuntu. install efibootmgr and gparted sudo apt-get install efibootmgr gparted

use gparted to turn off the ESP boot flag on the EFI partition.

find the file /EFI/ubuntu/grubx64.efi or /EFI/ubuntu/shimx64.efi

make a copy of it and rename it bootx64.efi. then move the file to /EFI/boot/bootx64.efi. replace the file that is there.

use gparted to reset the ESP boot flag on the partition.

2)windows like to tell efi to put 0000 first in the boot order. To keep windows from placing itself first in the boot order:

use efibootmgr to remove the entries in the efi boot memory.

sudo efibootmgr -b 0000 -B

repeat for all entries (except USB, CD and network boots), then reboot. make sure ubuntu is the first system you boot into so it gets placed in slot 0000

then boot your other systems. return to ubuntu and efibootmgr to verify ubuntu is in slot 0000.

Share:
34,581

Related videos on Youtube

Ramesh Pokala
Author by

Ramesh Pokala

Updated on September 18, 2022

Comments

  • Ramesh Pokala
    Ramesh Pokala almost 2 years

    I'm new to Ubuntu installation. Somehow I installed a dual boot with Windows 8 alongside Ubuntu by following this link, but today somehow always the grub command prompt is loading. I found an issue with hd0 in grub. I got to know that issue with grub, so I ran Boot-Repair through a live USB, and I got the following error:

    GPT detected. 
    Please create a BIOS-Boot partition(>1MB, unformatted filesystem, bio_grub flag). 
    This can be performed via tools such as GParted. Then try again.
    

    Using GParted I created a new partition with unformatted file system, but there is no option to manage flag so I'm unable to add 'bios_grub'. Below image is GParted view, and /sdb9 is a Linux partition.

    GParted

    • Admin
      Admin almost 7 years
      hilight the partition, click on "partition" menu, at the bottom s manage flags. however, if grub was booting before, this is not the correct fix. this fix if for mounting an legacy install on a gpt disk. it may prevent you from booting windows
    • Admin
      Admin almost 7 years
      Can you please share me correct fix?
    • Admin
      Admin almost 7 years
      reinstall grub in efi mode. search for answers o "chroot" to get into your system from a live CD then reinstall grub
    • Admin
      Admin almost 7 years
      You booted Boot-Repair in BIOS/CSM/Legacy mode, not UEFI mode. If Windows is UEFI you should always boot in UEFI mode, not in BIOS mode. Boot-Repair then is attempting to install a BIOS verions of grub that requires the bios_grub partition. But Windows 8 if from Vendor must be UEFI. Reboot and choose UEFI boot mode for Ubuntu live installer and add Boot-Repair to that.
    • Admin
      Admin almost 7 years
      I switched to UEFI mode. but still I'm getting same error
    • Admin
      Admin almost 7 years
      that is your problem. windows is installed in uefi mode yes? uvbuntu needs to be installed in efi mode
    • Admin
      Admin about 5 years
      Unsure about Gparted, but this is easy under Gdisk. When setting the partition type hex code to EF03, the flag is automatically set. From what I've read, it seems you can right click on a disk and click "set flags".
    • Admin
      Admin about 5 years
      With gdisk it is ef02 for the bios_grub partition. And ef00 for the ESP - efi system partition. The l command in gdisk lists the partition types. Both gparted's use of flags and gdisks use of codes is just to assign very long GUID type codes to a partition. en.wikipedia.org/wiki/GUID_Partition_Table to see actual GUID type codes: lsblk -o +parttype See also: rodsbooks.com/gdisk
  • Ramesh Pokala
    Ramesh Pokala almost 7 years
    There is no /EFI/ folder
  • Rod Smith
    Rod Smith almost 7 years
    ravery's filename references are relative to the root of the EFI System Partition (ESP), not the Ubuntu root. Copying the files as ravery suggests is probably unnecessary and includes other steps that are probably unnecessary. Deleting all the boot entries, as suggested here, might cause serious problems, so I strongly advise against it. There are better recovery methods.
  • ravery
    ravery almost 7 years
    @Rod I wrote them as reference by the sytem partition because if he is mounting from a live cd the ubuntu path is /media/<drive id>/efi/boot. and it never cause serious problems. this will always fix the problem when using windows cause the computer to boot windows instead of grub. this setup is also required for most usb boot drives.
  • ravery
    ravery almost 7 years
  • Rod Smith
    Rod Smith almost 7 years
    @ravery, my comment on the file reference was not a criticism; it was an explanation to Ramesh as to why he did not see the directory. As to your claim that your procedure never causes problems, I have seen this procedure cause problems! The system in question lost its ability to store any boot entries after they were all deleted. This was, of course, an EFI bug; but unless you're 100% sure that a given system will not be affected by such a bug, advising somebody to take that risk is completely reckless. EFIs vary significantly, so drawing conclusions from just one or two is very risky.
  • ravery
    ravery almost 7 years
    @Rod -- you are also drawing conclusions based on "one or two", but I will revise to leaving the USB, CD, and PKE boots, which are usually 0004,0005,0006 or higher, thus not affecting my solution which is to get grub in 0000.
  • Rod Smith
    Rod Smith almost 7 years
    A claim that something never causes problems is essentially an attempt to prove the null hypothesis, which is notoriously difficult, even with huge sample sizes. One counter-example is all it takes to destroy the null hypothesis. Because you've edited out the advice to delete all the EFI boot variables, I've undone my downgrade on your answer. Your procedure is still sub-optimal, addresses issues not mentioned in the question, and is not guaranteed to work; but at least it's no longer potentially dangerous.
  • ravery
    ravery almost 7 years
    a 2% problem rate doesn't nullify the answer either though. it is guaranteed to work and is described in the manual you keep pointing me too. this fix is necessary for systems that only allow device boot selection instead of OS boot selection, granted this population is getting smaller but still exist. PS: usb boot most frequently required the default media path (efi/boot/bootx64.efi) regardless of how it will boot the internal drive. your docs describe it as device boot vs OS boot .... my current system gives both options. but requires device boot for usb plugins
  • Ramesh Pokala
    Ramesh Pokala almost 7 years
    Already the boot option was UEFI. So copied rEFInd to USB. In refind I have selected linux. But I was landed to console,but from there 'startx' command not working to launch Desktop
  • Rod Smith
    Rod Smith almost 7 years
    Please start a new question about your X (startx/GUI) problem, as that's entirely unrelated to your boot/GRUB problem.
  • Radvylf Programs
    Radvylf Programs about 5 years
    Isn't esp for EFI? It should be bios_boot or maybe the legacy_boot option.