Skip to content

Instantly share code, notes, and snippets.

@hitorilabs
Last active October 3, 2023 21:17
Show Gist options
  • Save hitorilabs/bc47f2f5ebbd8f99181a9819260422fc to your computer and use it in GitHub Desktop.
Save hitorilabs/bc47f2f5ebbd8f99181a9819260422fc to your computer and use it in GitHub Desktop.

If you install windows on a machine that already has ubuntu, it will overwrite the MBR (Master Boot Record).

This is a guide that will allow you to keep boot priority on ubuntu (EFI)

1. re-install grub

grub-install onto the device that you installed ubuntu on (don't specify partition e.g. /dev/nvme0n1)

sudo grub-install /dev/<device_with_ubuntu>

2. update the grub config

typically it will have GRUB_TIMEOUT_STYLE=hidden and GRUB_TIMEOUT=0

# /etc/default/grub

...
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=1
...

Then run the update command

sudo update-grub

4. add entry for booting into windows

# /boot/grub/custom.cfg

menuentry "Windows (UEFI)" {
 search --set=root --file /EFI/Microsoft/Boot/bootmgfw.efi
 chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment