DEV Community

Cover image for Fixing GRUB: A Guide to Dual Booting Windows and Linux on UEFI GPT Systems
Shawon Saha
Shawon Saha

Posted on

Fixing GRUB: A Guide to Dual Booting Windows and Linux on UEFI GPT Systems

Dual booting Windows and Linux can be a great way to enjoy the best of both operating systems. However, issues can arise, particularly with the GRUB bootloader, which is essential for selecting which OS to boot into. If you find that your computer boots directly into Windows without showing the GRUB menu, you may need to fix GRUB. This blog post summarizes a helpful video guide on how to resolve this issue using Ubuntu installation media.

Understanding the Problem

When you install both Windows and Linux on a single hard drive, the GRUB bootloader should allow you to choose between the two operating systems at startup. However, sometimes GRUB can go missing or fail to display due to various reasons, such as system updates or changes in boot order. In this case, the computer boots straight into Windows, leaving you unable to access your Linux installation.

Step-by-Step Guide to Fixing GRUB

1. Boot into Ubuntu Installation Media

To begin fixing GRUB, you will need to boot from an Ubuntu installation media (USB or DVD). You can download the latest Ubuntu ISO from the official website. Once you have created your installation media:

  • Insert it into your computer and restart.
  • Select "Try Ubuntu" when prompted.

2. Open Terminal and Mount Partitions

Once you're in the live session of Ubuntu:

  • Open a terminal window by searching for "Terminal" in the applications menu.
  • First, you need to identify your partitions by running:
  sudo fdisk -l
Enter fullscreen mode Exit fullscreen mode

This command will display your drive structure. You’ll typically see partitions like /dev/sda1 for EFI and /dev/sda5 for your Linux filesystem.

  • Next, mount the necessary partitions. For example:
  sudo mount /dev/sda1 /mnt
  sudo mount /dev/sda5 /mnt/ubuntu
Enter fullscreen mode Exit fullscreen mode

This mounts your EFI partition and your Linux filesystem so that you can make changes.

3. Install and Update GRUB

Now that your partitions are mounted, you can install GRUB:

  • Change root into your mounted directory:
  sudo chroot /mnt
Enter fullscreen mode Exit fullscreen mode
  • Install GRUB on your disk (usually /dev/sda):
  grub-install /dev/sda
Enter fullscreen mode Exit fullscreen mode

If you encounter a warning about EFI variables not being set, ensure that you've correctly mounted the EFI partition.

  • After successfully installing GRUB, update it with:
  update-grub
Enter fullscreen mode Exit fullscreen mode

This command scans for installed operating systems and generates a new configuration file for GRUB.

4. Verify Boot Entries

To ensure that everything is set up correctly, check the EFI boot manager:

efibootmgr -v
Enter fullscreen mode Exit fullscreen mode

You should see an entry for Ubuntu in the boot order. If it’s not there or not prioritized correctly, you may need to adjust it using efibootmgr.

5. Reboot and Test

After completing these steps:

  • Exit the terminal and reboot your computer.
  • Remove the installation media when prompted.

Upon rebooting, you should see the GRUB menu allowing you to select either Ubuntu or Windows.

Conclusion

Fixing GRUB in a dual-boot setup with Windows and Linux can seem daunting, but following these steps can help restore access to your Linux installation. By using Ubuntu installation media and executing a few commands in the terminal, you can resolve boot issues and enjoy seamless switching between operating systems.

For detailed visual guidance, check out the video linked above. Happy dual booting!

Top comments (0)