Fix broken boot-loader

Note: This tutorial is specific to fixing a broken boot-loader on installed systems. If your problem is not broken boot-loader see this tutorial or the other tutorials in English/Resources section. This is written with consideration for less technical users.

There are several ways to fix or recover a broken boot-loader with installed OMLx systems.

  • Use any current OMLx iso booted ‘Live’. This is what we will describe here.

  • Use the Super Grub2 Disk. It has it’s own instructions. I will also post a step by step in the next post in this thread.

To do this from the OMLx iso you will need to know the disk and root partition device name. Let’s get started:

Most of you know this but after each command or command string you press the Enter key to execute the command or command string.

  1. Boot the iso.

  2. Open Konsole (terminal) type su - to become root, this time you don’t need a password because you are in OMLx iso ‘live’.

  1. Type fdisk -l and find your disk and root partition device name. The disk name will be something like Disk /dev/sda or for a nvme SSD Disk /dev/nvme0n1. The root partition device name will be listed under “Device” and have an addition number something like /dev/sda1 or for nvme SSD /dev/nvme0n1p4.

  1. Now we mount the root partition in Konsole:

    # mount >partition device name< >destination directory<

    Like this example:

    # mount /dev/sda2 /mnt

    or if you have a nvme SSD like:

    # mount /dev/nvme1n1p4 /mnt

  1. Next run this command exactly (copy and paste it):

    # for i in /proc /sys /sys/firmware/efi/efivars /run /dev /dev/pts; do mount --bind $i /mnt$i; done

  1. Now we will use chroot command to enter the remote system we are trying to repair:

    # chroot /mnt

Note how the shell identifier has changed from [root@omv-1602 ~]# to [root@omv-1602 /]# this indicates that our chroot to the remote system was successful.

  1. Next for UEFI boot systems we need to mount /boot/efi in the chroot system we want to fix.

    # mount /boot/efi

  1. Next we update the grub2 menu:

    # update-grub2

  1. Now we install grub2 boot-loader, here use the name of the drive you want to boot from:

    # grub2-install >HD or SSD device name<

    Example for conventional HD something like:

    # grub2-install /dev/sda

    Or for nvme SSD something like:

    # grub2-install /dev/nvme1n1

Proof! Boot-loader successfully installed on Disk /dev/nvme1n1.

  1. Now we exit chroot and unmount stuff.

    # exit

Use the arrow up key to find our mount command:

# mount /dev/nvme1n1p4 /mnt

Edit that to the umount command like this:

# umount -l /dev/nvme1n1p4 /mnt

We’re done. We upgraded grub2 menu in remote system and installed grub2 boot-loader to disk.

  1. Reboot

Anyone with problems or questions about this please post in English/Support forum or reach out to us on OpenMandriva Chat. If you spot any errors or have suggestions let us know.

(Tested using ROME iso # 1602 2022-12-31.)

Thanks to developer/project leader @bero for providing the command string in step 8 that made this work.

2 Likes

There is a tour that explains the general working of the Super Grub2 disk here.

To use the Super Grub2 Disk for OMLx systems:

  1. Download Super Grub2 Disk stable. Download the first entry in the list. It is marked Recommended.

  2. This is an .iso file you can burn to either CD, DVD, or flash drive.

  3. Boot as you would any .iso or installation media.

  4. Select the first entry in the Super Grub2 menu list:

    Detect and show boot methods

  5. Wait, the detection takes some time. In testing on older ASUS noteboot it takes 1 1/2 to 2 minutes when using a flash drive.

  6. The list will show all the bootable kernels on the computer and what partitions they belong to. User should be able to figure out which one they want for repairs. If you are new to this type of work it may take 2 or 3 tries for you to figure this out. Boot into your selection. You can remove the Super Grub2 media after booting in to you system. The entry type you want to see will have something like:

    Linux /boot/vmlinuz-6.0.9-desktop-1omv22090

    Of course your kernel version may be different. The entries that say (single) will boot to single user mode. single user mode is recovery mode. The entries without that should boot to graphical desktop.

  7. Repair and reinstall boot loader:

    7a.Open terminal (Konsole) and type or copy and paste:

    sudo update-grub2

    7b. Next you to need type:

    sudo fdisk -l

    to list your storage devices so you can determine where to install the boot-loader. For conventional hard drive it will be something like /dev/sda for NVMe device something like /dev/nvme0n1. The command to install the boot-loader would then be:

    7c. Install the boot-loader:

    `sudo grub2-install /dev/sda`
    
    or 
    
    `sudo grub2-install /dev/nvme0n1`
    

    7d. Reboot to test your work.

Anyone with problems or questions about this please post in English/Support forum or reach out to us on OpenMandriva Chat. If you spot any errors or have suggestions let us know.

(Super Grub2 Disk stable tested 2022-11-19)

2 Likes