How to manually define the grub prefix variable

grub2

My grub broke, I don't know what caused it, it happened after I booted off a usb live image of a linux distro I was going to try to install, but I was only in the anaconda setup menu, the installation itself had not started yet. he installer froze out of the blue before I could start the installation, and I had to reboot the system. After I did somehow my grub installation on /dev/sdb broke and I can't boot into my existing OSes.

My setup is as follows: /dev/sdb1 (Boot), /dev/sdb3 (Arch Linux Root) /dev/sdb2 (Windows boot) /dev/sdb4 (Empty partition, reserved to be used as an LVM for other linux distros I intend to install).

The grub prefix should be (hd1,msdos1)/grub, but when I try to reinstall grub and fix it, it for some reason always wants to put (hd1,msdos3)/boot/grub as the prefix and root.

When I try to boot it gives me the typical error: file '/grub/i386-pc/normal.mod' not found, and I'm a little bit confused since the grub-install command runs fine on arch reporting no errors, but still doesn't install grub correctly.

This is what I do to boot from grub rescue:

set prefix=(hd1,msdos1)/grub
insmod normal
normal

When I do that it loads correctly, now I only need a way to define this manually when grub is installed. Also, just to be clear, running grub-install again does not fix the problem, only repeats it. Grub seems to expect me to have it installed on /boot/grub on /dev/sdb3 when it is in fact installed on /grub on /dev/sdb1

Best Answer

E.G.: grub-install --boot-directory=/media/USERNAME/Mounted_BootVolume/ --force /dev/sda3

where /dev/sda3 is the "Patch-Core-Onto-Partition" and may be (but doesnt have to be) the same as Mounted_BootVolume.

".../grub" as the trailing-target-dir obviously cannot be changed

taken from manpage: --boot-directory=... install GRUB images under the directory DIR/grub instead of the boot/grub dir

P.S.: the new custom-dir is implicitly reflected by any boot-up of the grub-shell (i.e. grub.cfg needs no added prefix= lines) AFAIK

Related Question