Repair Linux grub boot loader.


You might have installed a Linux distro and you would like to have access to grub, or you have dual booted Windows and Linux and now your computer is booting straight to Windows or Linux installation. This article will provide your with information necessary to fix this problem.


  1. Boot from a live USB/DVD or another installation (If you have one on a USB/external drive).

  2. Run any of the following commands to determine the partition number of the installation you want to fix: lsblk, sudo fdisk -l, sudo blkid, or check in Gnome disks app or GParted.

    If your main partition is on an LVM, the device will be located in: /dev/mapper/{volume}--{os}--root, where {volume} is the LVM volume name and {os} is the operating system. You could execute the following command to get the exact name. i.e /dev/mapper/ubuntu--vg-ubuntu--lv.

    ls /dev/mapper

  3. Mount the target partition by running the following command.

    sudo mount /dev/{sdaX} /mnt

    Replace sdaX with the correct name i.e sda2 (The one you got from the previous section). If you have a separate /boot, /var, /usr or /home partitions, mount the partitions to /mnt/boot, /mnt/var, /mnt/usr and /mnt/home respectively.

    sudo mount /dev/sdaX1 /mnt/boot

    sudo mount /dev/sdaX3 /mnt/usr

    sudo mount /dev/sdaX4 /mnt/home

    sudo mount /dev/sdaX2 /mnt/var

    Make sure to replace the sdaX1, sdaX2, sdaX3 and sdaX4 with the correct name and partition numbers.

  4. If grub is not installed, install it using the following commands.

    If your system is running using Legacy/BIOS/MBR:

    sudo apt install grub-pc

    If your system is running using UEFI/EFI:

    sudo apt install grub-efi

    Then open /etc/default/grub and uncomment GRUB_DISABLE_OS_PROBER=false if you like to have other installed operating systems listed in the grub menu (add the entry if it is missing).

    Then run grub-update. If the command is missing run:

    sudo grub-mkconfig -o /boot/grub/grub.cfg

  5. For Legacy boot, install grub in the target system drive using the following command. Make sure to replace sdaX with the one you got in step 2.

    sudo grub-install /dev/{sdaX}

    If your system is using UEFI, first mount the efi partition using the following command, you can confirm first which partition is the efi partition (chances are it is /dev/sda1).

    sudo mount /dev/sda1 /boot/efi

    Then install using the following command:

    sudo grub-install /dev/sda