Updated answer on Sep 27, 2020:
Based on additional experience, I can now update my answer.
Presumably your goal (beyond merely installing packages) is to actually make a disk that can boot on both BIOS and EFI systems.
If you have a disk that can already boot on BIOS systems, you may be able to add EFI boot capability by running the below commands. Please note that (1) the disk will need to have a valid, properly formatted ESP (EFI System Partition), (2) the ESP will need to be mounted at /boot/efi
and (3) the disk may need to have a GPT (GUID Partition Table) rather than MBR (Master Boot Record). Assuming all that, the following commands worked for me:
$ sudo apt-get install grub-efi-amd64-bin
$ sudo grub-install --force --removable --target=x86_64-efi \
--efi-directory=/boot/efi --bootloader-id=Ubuntu
If you have a disk that can already boot on an EFI system, you may be able to add BIOS boot capability by running the below commands. Please note that (1) your disk may need to have a GPT (which it probably does) and (2) if your disk has a GPT, the GPT will need to specify a "Legacy BIOS boot" partition. Assuming you meet these preconditions, the following commands may work for you. (I have not tested these commands, but I suspect they might work.) Replace /dev/sdX
with the appropriate device (often /dev/sda
).
$ sudo apt-get install grub-pc-bin
$ sudo grub-install /dev/sdX
In either case, it probably does not hurt to rerun update-grub
after making the above changes.
$ sudo update-grub
For your reference, here is the Grub documentation.
Aside: I can view my GPT partition table by running sudo gdisk -l /dev/sdX
. For example, my Legacy BIOS boot partition looks like this:
Number Start (sector) End (sector) Size Code Name
1 34 2047 1007.0 KiB EF02 2004_bios_boot
Note that ubfan1's answer said that difference between the configuration files for the "legacy" and "UEFI" versions of Grub may cause problems. While such differences exist, I think they may not be relevant (or may only be minimally relevant) to this situation. "Legacy Grub" is version 1 of Grub. Whereas "Legacy boot" is booting via BIOS. Grub version 2 (commonly called "Grub") does support both BIOS and EFI booting. So don't confuse "legacy Grub" with "legacy booting".
Original answer on Sep 18, 2020:
As described in ubfan1's answer, you can install both grub-pc-bin
and grub-efi-amd64-bin
.
But note that there are some files in the grub-pc
and grub-efi
packages themselves. It appears that the files themselves all have distinct paths. So the files themselves do not conflict.
https://packages.ubuntu.com/focal/amd64/grub-pc/filelist
https://packages.ubuntu.com/focal/amd64/grub-efi/filelist
https://packages.ubuntu.com/focal/amd64/grub-efi-amd64/filelist
As for why the restriction is imposed, I can only speculate. Some possible reasons:
If you look at this answer, it appears to be recommended to install the EFI version of Grub from inside a system that booted in EFI mode. So it is possible that EFI Grub is installed in a system specific manner.
It is possible that the Ubuntu developers do not want to support multiple bootloaders on the same system. It is probably difficult to test and provide QA for such a setup.
It is possible that both EFI and BIOS Grub are configured to use the same configuration file (probably /boot/grub/grub.conf
). (And, as ubfan1 mentioned, the EFI vs BIOS versions of Grub may have different capabilities.) I believe this is an arbitrary limitation, that is, different installations of Grub could be configured to use different configuration files.
As an aside: I recently converted my BIOS system to EFI. It seems that the disk can (at least at present) successfully boot in either mode.
If you want to create a disk that boots in both modes, I would recommend installing the whole OS in EFI mode, and then manually trying to add a BIOS version of GRUB (or using Syslinux). I say this because I have much more experience installing and troubleshooting BIOS bootloaders. An EFI expert might recommend the reverse.
deb
so it doesn't tellapt
ordpkg
that it conflicts with the BIOS package? – Melab Aug 28 '20 at 18:02