boot – Rebuilding grub with LVM2 and UEFI

Trying to restore my grub boot loader for Ubuntu 22.04, but a weird anomaly during the rebuild process changes the boot menu to CentOS. I have tried several rebuild attempts from many different sources including superuser. Below is the latest process I attempted by combining techniques from several different sources (booting from a Live Ubuntu memory stick):

  • Ensure LVM2 is installed

     apt install lvm2
     modprobe dm-mod
     fdisk -l
    
  • Find the device with the LVM partition, in my case: /dev/nvme0n1p3

     uname -m
    
  • Ensure that the current operating x86 versus x86_64 matches the operating system you are trying to repair

     lvscan
     lvdisplay
     mkdir /mnt/home
     mkdir /mnt/root
     mount /dev/new_name/home /mnt/home
     mount /dev/new_name/root /mnt/root
    
  • Initialize your swap partition if necessary:

     swapon /dev/new_name/swap
     mount --bind /run /mnt/root/run
     mount --bind /mnt/home /mnt/root/home
     mkdir /mnt/boot
     mount /dev/nvme0n1p1 /mnt/boot
     mount --bind /mnt/boot /mnt/root/boot/efi
     for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt/root/$i; done
     chroot /mnt/root /bin/bash
     grub-install --recheck /dev/nvme0n1
    

Results:

   Installing for x86_64-efi platform.
   grub-install: warning: EFI variables cannot be set on this system.
   grub-install: warning: You will have to complete the GRUB setup manually.
   Installation finished. No error reported.

After that:

update-grub
exit

After rebooting… still getting boot CentOS for the grub menu, and still get the warning messages:

/dev/centos/root, /dev/centos/swap, and /dev/mapper/centos-root does not exist.

Then the boot process enters emergency mode and generates the rdsosreport.txt file.
I have the report… but do not see a way to attach it.

Any tips on getting my grub to recognize Ubuntu? BTW, I did mount a CentOS 7 LVM2 partition previously trying to look at some data I was trying to save. I was able to mount it successfully… hoping that process did not cause these anomalies.

Appreciate any help 🙂

Read more here: Source link