[Arch Wiki] Grub installation Clarification


Quoting directly from the Arch Wiki:

Install the grub package. (It will replace grub-legacyAUR if that is already installed.) Then do:
# grub-install --target=i386-pc */dev/sdX*
where i386-pc is deliberately used regardless of your actual architecture

Why is i386-pc deliberately used regardless of the actual architecture? Is it because i386-pc is fine for both 64 and 32 bit systems?

It isn’t the architecture exactly, it is the platform as described by grub. For a x86 PC, you will almost always want either i386-pc for BIOS or x86_64-efi for UEFI.

The full list of options is:

arm-coreboot, arm-efi, arm-uboot, arm64-efi, i386-coreboot, i386-efi, i386-ieee1275, i386-multiboot, i386-pc, i386-qemu,  i386-xen,  i386-xen_pvh,  ia64-efi,  mips-arc,  mips-qemu_mips,  mipsel-arc, mipsel-loongson, mipsel-qemu_mips, powerpc-ieee1275, riscv32-efi, riscv64-efi, sparc64-ieee1275, x86_64-efi, x86_64-xen

Thanks for the swift response @dalto

That makes sense. Mine is a UEFI, and I did see a x86_64-efi directory inside my /boot/grub/ directory. Can you provide an explanation for the rationale behind deliberately using i386-pc as suggested in the Arch Wiki? I assume there is a good reason behind it? The default value for --target is x86_64-efi though (according to grub-install --help).

The default for --target is i386-pc according to https://man.archlinux.org/man/grub-install.8
This is not the case according to grub-install’s help list.

So I have the following output for lsblk:

sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0   200G  0 part /
├─sda3   8:3    0   260G  0 part /home
└─sda4   8:4    0   5.3G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom

If I were to safely run grub-install, I can do it with:
sudo grub-install /dev/sda

Is that correct?

Because you are reading the section of the Arch wiki related to MBR installs so it is recommending the appropriate approach. If you look at the section for UEFI installs, it provides an example of:

# grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB

Ah, no. For UEFI installs, you need to target the partition.

However, can you explain why you are running grub-install? The exact command varies depending on the circumstances.

This is what happens when you click into an Arch Wiki page and use Ctrl+F to look for keywords and then start reading the first keyword you find without considering the surrounding sections…
Lesson learnt.

Wasn’t planning to run it. I saw the article you wrote here which discourages running grub-install post upgrade. I was doing some research in the hopes of learning more about the topic. This bout of curiosity was brought upon by a warning message I saw in my pacman logs.


[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET] :: To use the new features provided in this GRUB update, it is recommended
[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET]    to install it to the MBR or UEFI. Due to potential configuration
[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET]    incompatibilities, it is advised to run both, installation and generation
[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET]    of configuration:
[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET]      $ grub-install ...
[2022-12-10T00:46:40+0800] [ALPM-SCRIPTLET]      $ grub-mkconfig -o /boot/grub/grub.cfg

For most people who want to run it post-upgrade, the best command for UEFI is usually grub-install --no-nvram.

As long as you have a basic setup that should work fine.