Restoring dual boot of Windows 10 and Linux when Windows rewrites the Bootloader

Windows will try hard to remain the one and only operating system on your laptop. After a major update of Windows 10 my Ubuntu was no longer accessible as the Windows update process replaced the Grub bootloader with the Windows bootloader, booting only Windows.

The following sequence of command line parameters will restore Grub. These commands are valid if your are using BTRFS for your root partition, booting using EFI and using and NVMe drive.

First get a USB pen drive, download any recent Linux distribution, write it onto the USB pen drive and boot into the live system.

Afterwards you have to determine which is the drive Linux is installed on and your Linux root partition:

`fdisk -l`

which outputs on my system

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F687432F-DB86-4B88-8CB2-DBB55255216B

Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 534527 532480 260M EFI System
/dev/nvme0n1p2 534528 567295 32768 16M Microsoft reserved
/dev/nvme0n1p3 567296 198828031 198260736 94,6G Microsoft basic data
/dev/nvme0n1p4 445640704 498069503 52428800 25G Microsoft basic data
/dev/nvme0n1p5 498069504 500117503 2048000 1000M Windows recovery environment
/dev/nvme0n1p6 198828032 426108927 227280896 108,4G Linux filesystem
/dev/nvme0n1p7 426108928 445640703 19531776 9,3G Linux swap

From this output the Linux root drive is /dev/nvme0n1p6 and the EFI partition is /dev/nvme0n1p1. Your output may vary.

Mount the existing root partition:

sudo mount -t btrfs -o subvol=@ /dev/nvme0n1p1 /mnt 

Mount all other linux system folders :

for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done

Mount your EFI directory using the following command:

sudo mount /dev/nvme0n1p1 /mnt/boot/efi

chroot into your install

sudo chroot /mnt

Now that you are logged in your installation (not the Ubuntu Live) just do

grub-install /dev/nvme0n1

Replace `nvme0n1` with your main drive. After booting Grub should greet you again with Linux and Windows as options to boot.


Information derived from and