Methods of payment Abuse

How to restore Grub after Windows installation

07.07.2024, 19:41

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.

Why restore Grub after installing Windows?

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.

Restoring Grub

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.

Starting CMD

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:

Cmd запуск

Connect EFI partition

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

How to restore Grub after Windows installation

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:

How to restore Grub after Windows installation

This partition needs to be assigned a letter. To do this, perform:

$ sel vol 2
$ assign letter=I:

How to restore Grub after Windows installation

Find bootloader

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

How to restore Grub after Windows installation

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.

Restoring GRUB

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.

Why recovery fails?

There are several reasons why restoring Grub can be difficult after Windows installation. Here are some of the possible reasons:

  1. Bootloader Overwriting: When installing Windows, especially on the same partition where Linux is installed, Windows may overwrite the Grub bootloader with its own bootloader, causing Grub to no longer be available.
  2. UEFI and Secure Boot: On computers with UEFI and Secure Boot enabled, additional configuration may be required to restore Grub after Windows installation.
  3. Different partitions and disks: If different operating systems are installed on different partitions or disks, this can also affect the way Grub is recovered.
  4. Incorrect recovery: sometimes errors or incorrect commands may occur while trying to recover Grub, causing the recovery procedure to fail.
  5. Windows updates: after Windows updates, there may be problems with the Grub bootloader due to changes in the system.

To successfully restore Grub after Windows installation, it is recommended to use specialized instructions for your specific configuration and Linux distribution