If you have two operating systems on your computer, Windows and Linux, and you have upgraded your Windows from 7, 8, or 8.1 to the newest Windows 10, there may be issues with the Grub boot loader when using UEFI Secure Boot. During a system upgrade, Windows 10 will simply erase the Grub bootloader and write its own bootloader in there.
Next, after the system reboots, the user expects to see a Grub operating system selection menu, but instead the new Windows 10 boots. It may seem that there is no way to access Ubuntu or that you can't run Ubuntu alongside Windows 10. But there isn't.
After installing Windows, you may need to restore the Grub boot loader if you have a Dual Boot with Linux. Windows can overwrite the Grub boot loader during installation, which can cause Linux to stop booting. Restoring Grub will allow you to choose your operating system when you start your computer and restore access to Linux.
Often experts advise you to install Ubuntu on another disk, but there is a simple solution. You can always use the standard method, for example, using a LiveCD disk. But if you are using UEFI, there is a solution using Windows 10.
First, click on the search icon in Windows, type cmd there and find the Windows Command Prompt. Right click on it and select Run as administrator:
Next you can try to guess what the name of the Grub boot loader file on the EFI partition is, but you can do the opposite and just look. To mount the EFI partition run diskpart. To do this run:
$ diskpart
Then bring up a list of available disks:
$ list disk
Select as active the disk where Windows 10 is installed and where the EFI partition is currently located:
$ sel disk 0
Bring up a list of partitions on the disk:
$ list vol
Locate the EFI partition, it is usually formatted to the FAT file system and takes up about 100 megabytes of space. In this case, it is volume 2:
This partition needs to be assigned a letter. To do this, perform:
$ sel vol 2
$ assign letter=I:
Now you need to find the boot loader file on the EFI partition. But you can't open this partition in Explorer, you need to use the command line only. Close DiskPart and execute:
$ cd /d I:
Then use the dir command to find the Grub bootloader. For example:
$ dir EFIUbuntu
There is a file grubx64.efi
here. This is it. The bootloader may be called differently in other distributions, which is why I told you how to look it up.
Now copy and run this command:
bcdedit /set {bootmgr} path EFIubuntugrubx64.efi
You won't have to enter a password if you have administrator privileges and the program should work fine. This command will write back the Grub bootloader instead of the Windows 10 bootloader.
If the command returned an error, you can roll back the changes with this command:
$ bcdedit /deletevalue {bootmgr} path EFIubuntugrubx64.efi
You can then enable the Windows 10 bootloader:
$ bcdedit /set {bootmgr} path EFIMicrosoftBootootmgfw.efi
Restart your computer and you will see the familiar Grub on the screen. This completes the Grub recovery process.
There are several reasons why restoring Grub can be difficult after Windows installation. Here are some of the possible reasons:
To successfully restore Grub after Windows installation, it is recommended to use specialized instructions for your specific configuration and Linux distribution