I know this is an old question asked a million times but every answer I find is always incomplete.
I had installed Windows but then my wifi didn’t work in Windows after reboot, it has a driver and I know the RFKILL flag can be enabled by weird/faulty drivers such as those in Linux also. But anyway after installing Windows I needed to get Grub2 back.
Long story short I had to boot with a Kubuntu Live CD because I couldn’t get my LVM mapped after cryptsetup open (for LUKS) on the volume/partition that contained the root logical volume for openSUSE.
So I am in Kubuntu and I do:
cryptsetup open /dev/sda5 sda5_crypt
mount /dev/linux/root /mnt
mount --bind /dev/ /mnt/dev
mount --bind /proc/ /mnt/proc
mount --bind /sys/ /mnt/sys
At that point I am going to look for openSUSE’s way of installing grub2.
chroot /mnt → I am in openSUSE’s environment now.
grub-install /dev/sda → results in error: use grub-install.unsupported or yast2 bootloader
But yast2 bootloader requires an X session and I can’t get it to run in Kubuntu’s live session.
grub-install.unsupported /dev/sda → results in error: /dev/md-2 does not have matching BIOS device
grub2-install /dev/sda → results in error: it detects my cryptsetup and wants me to pass an option to grub such as GRUB_ENABLE_CRYPTODISK=1.
I make the required change, it still complains. Turns out the error message is wrong, it has to be “y” not “1” as the value.
So now grub2 installs. But it doesn’t install the openSUSE menu.
I get a prompt at reboot asking for my password to the LUKS, which is not even needed to load the menu. I enter my password.
I get a grub prompt. I try various things.
grub> linux (hd0,msdos3)/vmlinuz root=/dev/linux/root → this one ends in a root device not found
grub> linux (hd0,msdos3)/vmlinuz root=(lvm/linux-root) → this one results in a different error but the system still locking up.
grub> initrd (hd0,msdos3)/initrd
grub> boot
This fails. Next time I remember the configfile option.
grub> configfile (hd0,msdos3)/grub2/grub.cfg
It loads beautifully giving me the default openSUSE boot loader.
And I’m in. Now I run kdesu yast2 bootloader, and it installs grub2 for me.
There’s gotta be an easier way, right?. For years I’ve had this problem, also with Kubuntu, of not knowing how to install or recover grub. All of the options I’ve seen always failed. This was the only time I’ve succeeded thus far. I’m generally apprehensive of installing Windows or losing my MBR because of this and I generally just take out an USB stick or SD card and install grub on that so I always have a way back into my system.
Pretty fancy that Grub can ask for the password but it’s butt-ugly of course ;-D.
So what is the tried and tested way to get Grub back?. I had tried the openSUSE rescue option from the DVD but it wouldn’t load my LVM after the cryptopen. I believe I needed vgchange -ay <volname> (volume group name) to get it activated, not sure. So I had to get into Kubuntu because it does it automatically there.
What’s the answer?..?.