2

My HDD uses GPT. I've set my boot mode to UEFI only. My partitions are:

/dev/sda

/dev/sda1 Grub 300MiB FAT32
/dev/sda2 Linux 97.66GiB ext4
/dev/sda3 Windows 97.66GiB NTFS
/dev/sda4 Microsoft_Reserved 16MiB unknown
/dev/sda5 Data 726.13GiB NTFS 
/dev/sda6 Swap 9.76GiB linux-swap 

I had set up grub on /boot/efi on /dev/sda1 during the installation of Sparky linux on /dev/sda2. Everything was working fine and I could choose between Linux, its recovery, Windows 10 and BIOS from the grub menu when I set it as the first in the boot priority order.

I now replaced Sparky Linux with Solus Linux. But the problem is that grub no longer works. Booting from the grub partition gives me the following error:

error: file `/boot/grub/x64_86-efi/normal.mod` not found.
Entering rescue mode
grub rescue>

Booting into linux and doing sudo update-grub gave me:

$ sudo update-grub
Generating grub configuration file ...
Found background: /usr/share/backgrounds/splash.tga
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
done

but that didn't seem to fix it. My HDD currently has 3 bootloaders I think: Linux, Windows and grub, at least that's the things being shown in the boot priority menu in the BIOS.

Edit: I tried to reinstall grub and now I have two grub bootloaders, neither of them which work.

Output of lsblk:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   300M  0 part 
├─sda2   8:2    0  97.7G  0 part /
├─sda3   8:3    0  97.7G  0 part 
├─sda5   8:5    0    16M  0 part 
├─sda6   8:6    0 726.1G  0 part 
└─sda7   8:7    0   9.8G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  

I'm at a loss as to what to do to fix it. I just want to have the option to select my OS at boot.

  • You should backup your data using liveboot usb and then reinstall Windows and Solus – Arpit Agarwal Nov 8 '17 at 8:03
  • When you are in grub rescue, what is the output from ls? And did you install Linux to LVs? – bu5hman Nov 9 '17 at 13:42
  • @bu5hman Output of ls: (hd0) (hd0, gpt7) (hd0, gpt6), (hd0, gpt5) (hd0, gpt4) (hd0, gpt3) (hd0, gpt2) (hd0, gpt1) (cd0). Not sure what you mean by 'install Linux to LVs'. I use GPT, so there's no logical volumes or anything (correct me if I'm wrong) – Spikatrix Nov 10 '17 at 15:53
  • I asked about the LV's because it makes a difference to how to handle the paths to / and /boot/grub and also you need to load another module into grub to handle them at boot. If you are not using LV then hamna shida (no worries). – bu5hman Nov 11 '17 at 4:33
  • GPT and LVM are different things. You can have one without the other. Put the output of ls in your question, please. Always include all relevant information in the question. – Faheem Mitha Nov 11 '17 at 9:46
1

This linux.com link will explain how to recover from a broken grub through grub-rescue.

Basically you need to

ls (hd0,1)/
ls (hd0,2)/

and so on until you find the /boot/grub directory and also the vmlinuz and initrd.img files. Although the link expects these files to be in /boot/vmlinuz-x.y.z.blah you will probably see them as links in / which just point to the current kernel and initrd. If you don't, then just look in /boot/ and amend the below accordingly.

Judging from your lsblk /boot/grub may be on (hd0,1) and the rest of your linux OS is on (hd0,2).

Once you have found the partition with your OS, you could verify this with

cat (hd0,2)/etc/fstab

If these assumptions are correct then

set prefix=(hd0,1)/boot/grub  #tells grub where it can find insmod etc
set root=(hd0,2)              #tells grub where to find / 
insmod normal                 #loads normal module
normal                        #executes normal
insmod linux                  #loads the linux module
linux /vmlinuz root=/dev/sda2 #executes linux, loads the kernel and tells it where to find /
initrd /initrd.img            #loads the initrd
boot

Note the root=/dev/sdx command. If you omit this or point it to the wrong partition then you will get a kernel panic. If so then just REISUB and start again.

If the above doesn't work then try again changing the first line to

set prefix=(hd0,2)/boot/grub

Once you are in you can reinstall grub.

I like to use grub-customizer when fixing grub simply because it lets me see the boot options and setup in grub while I am still in linux and fix any issues before going for the reboot.

  • This mostly looks on target, though I'm not currently in a position to test this. But I seem to remember, from my own experience with similar breakages, that once normal has been executed, then I get access to the GRUB menu and don't need to type things in manually. Maybe normal brings the GRUB menu up? I forget. Can anyone confirm/clarify? – Faheem Mitha Nov 11 '17 at 10:34
  • As often as not, as soon as normal is executed then you get grub back and can boot from the menu. But it doesn't hurt to be aware of the whole process. – bu5hman Nov 11 '17 at 10:46
  • Thank you for the confirmation. Assuming, of course, there is a usable grub config/menu file in the first place. – Faheem Mitha Nov 11 '17 at 10:49
  • If not, then Cool Guy probably needs to reinstall grub as per Time4Tea direction below, but if reinstallation hasn't worked before then there may be another issue. Hence my previous query re LV's, since an installation to LV will require additional grub modules to handle them at boot as well as being to identify the actual location of grub ((hd0,1)/boot/grub or wherever). – bu5hman Nov 11 '17 at 11:09
  • LV should be handled automatically in theory. I use LV and don't have to do anything, in theory. Most likely the menu is still there and usable, since it exists on the system proper. But there is probably no point in discussing this further, since the poster has not responded to anything you or I have written. – Faheem Mitha Nov 11 '17 at 13:36
0

You should be able to re-install GRUB by doing the following:

  1. Boot up into Linux using a live USB/CD
  2. chroot to your Linux root partition (I assume /dev/sda2)
  3. mount /dev/sda1 at /boot/efi

  4. run sudo grub-install

What happens if you try that?

(NOTE: I recommend that you make sure your critical data is backed up first)

  • So, I did sudo mount /dev/sda2 /mnt and then sudo chroot /mnt which worked as expected. However, sudo mount /dev/sda1 /boot/efi failed with mount: /boot/efi: mount point does not exist. So I did cd /boot and then mkdir efi. Trying to mount the first partition again gave me mount: /boot/efi: special device /dev/sda1 does not exist. – Spikatrix Nov 10 '17 at 16:09
  • Can you post the output of the lsblk command? You may need to invoke mount with the -t msdos option, to indicate that /dev/sda1 is using a fat32 (Windows) filesystem. – Time4Tea Nov 10 '17 at 16:53
  • Added the output of lsblk in the question. Using sudo grub-install gave me grub-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory. when I used it directly from the installed linux and not via the Live USB – Spikatrix Nov 11 '17 at 3:21
  • Using mount -t msdos /dev/sda1 /boot/efi via the live USB gave me the same error as before mount: /boot/efi: special device /dev/sda1 does not exist. – Spikatrix Nov 11 '17 at 3:27
  • Ok. So, The problem was after chrooting, I couldn't mount any of the partitions. So I first mounted /dev/sda1 at /boot/efi, chrooted to /mnt which I had mounted to /dev/sda2. sudo update-grub gives me /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?) while sudo grub-install gives Installing for the i386-pc platform. grub-install: error: install device isn't specified.. Both sudo grub-install /boot/efi and sudo grub-install /dev/sda1 gives me Installing for the i386-pc platform. grub-install: error: cannot find a device for /boot/efi (is /dev mounted?) – Spikatrix Nov 11 '17 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.