Looking for some help with restoring the boot grub loader on Ubuntu 21.04. Last night I started the laptop and was greeted with a minimal bash-like error. I was able to find a way to repair/restore back to desktop but I no longer have the boot manager. Which is important because I use the win1o drive for work.
I have seen a few examples on how to restore the boot loader online but figured since we are all here it may be beneficial to get it out in the open as it will probably happen to others.
It looks like it went though fine. Here are the results
brian@brian-G750JM:~$ sudo apt install os-prober
[sudo] password for brian:
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
os-prober is already the newest version (1.77ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
brian@brian-G750JM:~$ sudo grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
brian@brian-G750JM:~$ sudo update-grub
Sourcing file /etc/default/grub' Sourcing file /etc/default/grub.d/init-select.cfg’
Generating grub configuration file …
Found linux image: /boot/vmlinuz-5.11.0-37-generic
Found initrd image: /boot/initrd.img-5.11.0-37-generic
Found linux image: /boot/vmlinuz-5.11.0-34-generic
Found initrd image: /boot/initrd.img-5.11.0-34-generic
Found Windows Boot Manager on /dev/sdb2@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings
done
That’s fantastic. I was looking at stuff that was saying I would need to boot from an iso/usb with ubuntu and all kinds of other stuff. I am very happy I asked. Thank you for sharing your wisdom. I’ll be saving this
My pleasure, as always, Brian!
You were fortunate to have been inside Linux. If you were stuck on Windows, it would have been a bit more complex of a process.
Yes. It re-installed Grub on the primary drive, which it defined as SDA. If - for some reason - your boot drive is SDB, you can redirect your BIOS to boot from the other drive. You haven’t lost your access as this boot loader can be installed everywhere.
Some instructions and Links for Repairing Grub from the Grub Prompt
There are some situations where you might find yourself booting to the Grub2 prompt. “Don’t Panic”!
This happened to me recently as I was trying to use the default usb-iso-boot-image installer (and I didn’t turn off power to my internal SSD - like [vasileios] recomended - doah!) And the default boot location for grub to locate the boot configuration got messed up.
I did some research and found the following technique to be helpful:
Situation where this became necessary:
Installing Linux to an external Harddrive (like an SSD) using the installer from the live usb
it destoys the grub partition on the boot partition by accident and you have to manually find the /boot/grub directory and run command to boot manually.
You have to boot manually using grub commands then
update grub
reinstall gub on the boot partion /dev/sda (or what ever disk your boot is on)
Helpful Websites for
MOST HELPFUL:
grub2 - GRUB starts in command line after reboot - Unix & Linux Stack Exchange
find the grub directory on the boot drive (likely hd0) use ls to find the grub.cfg in the grub directory
grub>ls -al
grub> ls
(hd0) (hd0,2) (hd0,1)
grub>ls (hd0,1)/boot/grub
type some grub commands to get things oriented so that it can find the boot drive
grub>set prefix=(hd0,1)/boot/grub
grub>set root=(hd0,1)
grub>insmod linux
grub>insmod normal
# this line will continue with the boot and should get your
# system back up and running so you can repair the grub install
# to the correct boot location
grub>normal
This should boot the system. Then once the system is back up
update grub
# Make sure grub is up to date
sudo update-grub
reinstall grub on the boot drive:
# NOTE: /dev/sda is just an example you have to find your own boot drive on your system.
grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
Very Helpful: How to Rescue a Non-booting GRUB 2 on Linux - Linux.com