104 — GRUB rescue

revision: Jun 22, 2022

Table of Content

Under EFI, boot order information is stored in NVRAM, and unfortunately, some EFIs will delete NVRAM entries that no longer exist. When you unplugged your boot disk, your firmware almost certainly deleted those entries. askubuntu.com/questions/706645

wikileaks.org/ciav7p1/cms/page_26968097.html

Recover your boot loader (if you unplug your boot disk) with efibootmgr askubuntu.com/questions/706645

Put a suitable boot loader in the fallback filename position (EFI/BOOT/bootx64.efi on the ESP). This could be a copy of GRUB or something else entirely. askubuntu.com/questions/706645

You may also find my rEFInd boot manager, placed on a USB flash drive or CD-R, to be useful for recovery in situations like this. It should at least get your system up and running again, from which point you can run efibootmgr or even do a full re-install of GRUB. Rod Smith <a href="https://askubuntu.com/a/706703"

https://askubuntu.com/a/706703

Any downside to using rEFInd instead of GRUB? askubuntu.com/a/760971

UEFI has its own NVRAM to remember boot entries. But when you unplug a drive it forgets them. You may get it to re-read ESP - efi system partition by cold booting, not rebooting several times. Or use efibootmgr from live installer to add entry back into UEFI memory. Or use Boot-Repair to reinstall grub. To avoid issue always create /EFI/Boot/bootx64.efi. Make it a copy of shimx64.efi if Ubuntu or Winodws boot file if only Windows. askubuntu.com/questions/668506/… –oldfred

BOOT PARTITION

On Ubuntu and other modern Linux distributions, all the files required to boot your computer are kept on different partition, called the Boot partition.

This file defines how GRUB boots into different operating systems and what kernels to use and many more.

/dev/nvme0n1p1  511M  5.3M  506M   2% /boot/efi                                 
$ sudo dd if=/dev/nvme0n1 of=/dev/sda conv=noerror,sync status=progress         

TRULY PORTABLE

58bits.com/blog/2020/02/28/how-create-truly-portable-ubuntu-installation-external-usb-hdd-or-ssd

https://askubuntu.com/a/706703

Applied to LG

-LG does not boot after creation external bootable disk (Toshiba CB) -followed askubuntu/questions below. Did not work. -then went to askubuntu.com/questions/88384

  1. Boot from live USB, in "Try Ubuntu" mode.

  2. Determine the partition number of your main partition.

  $ sudo fdisk -l                                                               
  $ sudo blkid
  $ GParted

(which should already be installed, by default, on the live session) can help you here. I'm going to assume in this answer that it's /dev/sda2, but make sure you use the correct partition number for your system!

3 Mount your partition: (Replace /nvme0n1p2 with the partition from step 2)

  $ sudo mount /dev/nvme0n1p2 /mnt                                              

4 Bind mount some other necessary stuff:

  $ for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done     

5 If Ubuntu is installed in EFI mode (see this answer if you're unsure), use sudo fdisk -l | grep -i efi or GParted to find your EFI partition. It will have a label of EFI. Mount this partition, replacing sdXY with the actual partition number for your system:

  $ sudo mount /dev/nvme0n1p1 /mnt/boot/efi                                     

6 chroot into your Ubuntu install:

  $ sudo chroot /mnt                                                            

7 At this point, you're in your install, not the live session, and running as root. Update grub:

  $ update-grub                                                                 

8 If you get errors or if going up to step 7 didn't fix your problem, go to step 8. (Otherwise, it is optional.)

this step was mandatory for me.

$ grub-install /dev/nvme0n1p2                                         
$ update-grub

9 If Ubuntu is installed in EFI mode, and EFI partition UUID has changed, you may need to update it in /etc/fstab. Compare it:

    $ blkid | grep -i efi                                             
    $ grep -i efi /etc/fstab

If current EFI partition UUID (from blkid) differs from the one in /etc/fstab, update /etc/fstab with current UUID.

10 If everything worked without errors, then you're all set:

    $ exit
    $ sudo reboot                                                               

At this point, you should be able to boot normally.

If you cannot boot normally, and didn't do step 8 because there were no error messages, try again with step 8.

Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 8 does. Experience helping users in chat has shown that step 8 is sometimes necessary even when no error messages are shown.

Boot Repair installation

$ sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt update         
$ sudo apt install -y boot-repair && boot-repair

GRUB>

grub> ls
grub> ls (hd0,gpt2)/
grub> root=(hd0,gpt2)
grub> configfile /boot/grub/grub.cfg                                            

select the entry to boot.

askubuntu.com/questions/159846/tried-to-boot-ubuntu-but-the-grub-rescue-prompt-shows-up-instead

askubuntu.com/questions/88384
step by step recovery.

phoenixnap.com

hackerearth.com

hackerearth.com

58bits.com

askubuntu

css detected: