0

I installed Ubuntu 21.10 on a new machine. Then I needed to dual boot Windows 10, so I booted to a live USB and shrunk the Ubuntu partition. Windows installed fine, but apparently squashed GRUB. I was able to recover using boot-repair from the live USB, but it boots to the GRUB prompt, where I have to manually:

set (seems to remember these between boots after I do it once):

prefix=(hd0,gpt2)/boot/grub
root=hd0,gpt2

I have to manually:

grub> linux /boot/vmlinuz-5.13.0-22-generic root=/dev/nvme0n1p2
grub> initrd /boot/initrd.img-5.13.0-22-generic
grub> boot

This successfully boots me into Ubuntu.  Once there, I ran boot-repair again. but when I reboot, I'm back at the GRUB prompt. I'd like a GRUB menu showing Ubuntu, Windows, etc.

Here's boot-repair's report: https://paste.ubuntu.com/p/FRgPjN9BGr/

note: I cobbled the above together from googling. I don't really understand what I'm doing and don't have experience with GRUB or bootloaders.

UPDATES: i tried boot-repair from the live USB again.

-if i use the recommended repair, it seems to do nothing other than generate this report: https://paste.ubuntu.com/p/xVXDqGPykW/ the results are the same as before (fails to boot and winds up at GRUB prompt with "Failed to open \EFI\UBUNTU Failed to load image \EFI\UBUNTU\ start_image() returned Invalid Parameter, falling back to bootloader")

-if i try "advanced" and don't change any options, i get the same as above with this report: https://paste.ubuntu.com/p/hbr7tpRFdZ/

-if i try "advanced" and add "Purge GRUB before reinstalling it," i get a dialog that says "GRUB is still present. Please try again." this is after confirming to remove GRUB after being asked to run: sudo apt-get purge --allow-remove-essential -y grub*-common shim-signed

at that point, i have no choice but to cancel.

-if i try "advanced" and add both GRUB purge and "Purge kernels then reinstall last kernel," it's been stuck for over an hour on "Purge kernels then reinstall last kernel on nvme0n1p2 (pur). This may require several minutes..."

  • 2
    boot-repair must be run from a live session. You can't run it from your installed system. Try again, but from a live session (Try Ubuntu from installation media). FYI, if you ever need to set up dual-boot config in the future, it's better to install Windows first. The Ubuntu installer knows how to install alongside Windows. The Windows installer doesn't care what's there before it and will change the boot priority to itself instead of GRUB. And Windows will not be added to the GRUB options automatically unless Windows is first. – Nmath Dec 31 '21 at 00:00
  • Ghe grub in the ESP which is only 3 lines is pointing to p3. Your p3 is shown as Microsoft Reserved & has that typical size but also as ext4. It must be unformatted. And the grub in the ESP must then use UUID of p2. You can just manually edit that /EFI/ubuntu/grub.cfg with UUID of p2, see line 226. Or use Boot-Repair's advanced mode to do a total reinstall of grub & kernel which will reset everything to correct defaults. You have to use gparted to change p3 to unformatted separately. – oldfred Dec 31 '21 at 04:41
  • thanks Nmath and @oldfred - i updated above, still stuck... – user1441998 Dec 31 '21 at 21:28
  • Post new link to summary report after your fixes. You did a full reinstall of grub, not just a grub-update? – oldfred Jan 01 '22 at 04:39
  • @oldfred - i edited the main question with what i did and the reports -- see after "UPDATES." basically, i checked "grub purge" and "kernel purge" under "advanced," and boot-repair has hung. i was thinking of using this method: https://askubuntu.com/questions/1253247/how-to-fix-or-remove-a-broken-kernel-ubuntu-20-04/1253346#1253346 to try to recover now, but i am unsure of how to kill boot-repair in a way that it won't leave a mess of apt cache locks. – user1441998 Jan 01 '22 at 05:08
  • @oldfred - i had started boot-repair in the background and closed its terminal, so i don't know how to figure out what all pid's it started. ps -e | grep repair brings up around 6 matches, and none of those have the pid for the apt-get process that is currently holding a bunch of cache locks... – user1441998 Jan 01 '22 at 05:08
  • I sometimes open synaptic & then try to update from terminal. I get the cache lock issue. You can only have one update process running at one time. Do you have any other program running besides Boot-Repair? – oldfred Jan 01 '22 at 15:50
  • @oldfred -- right, no i have nothing else running, i'm sure this is boot-repair's apt-get process. i can see in boot-repair's log (/var/log/boot-repair/...) that it seems to be apt-get which has hung, just after boot-repair asked it to purge linux-image-*... – user1441998 Jan 01 '22 at 17:01
  • You can manually edit /EFI/uubuntu/grub.cfg which has wrong UUID. See line 297 and actual / UUID on line 272 & 305. Copy correct UUID into the grub file. If mounted from live installer path will include that mount also. – oldfred Jan 01 '22 at 21:16
  • @oldfred, ok tried that, same results. here's boot-repair's latest: https://paste.ubuntu.com/p/nkWcdPrNXT/ – user1441998 Jan 01 '22 at 23:55
  • also asking here: https://ubuntuforums.org/showthread.php?t=2470507&p=14073470#post14073470 – user1441998 Jan 02 '22 at 00:28
  • Looks like it should boot. Only issue seems to be the Microsoft reserved is showing as ext4 and should be unformatted. – oldfred Jan 02 '22 at 04:43

1 Answers1

0

manually booting into the install, and doing grub-install and update-grub seemed to fix it. i'm not sure why, i feel like i did those a million times with no change. it could be that i did them from the live usb, i can't remember -- but people said it should work from there. i don't get it -- if anyone can figure out what all went wrong, please share!

thanks to @oldfred who kept helping me til it worked :)

https://ubuntuforums.org/showthread.php?t=2470507&page=2&p=14073576#post14073576