What GRUB is and why you might need it

GRUB (Grand Unified Bootloader) is the program that starts your computer and lets you choose which operating system to load. On a Windows 11 machine, you normally boot straight into Windows without seeing any menu. If you install Linux alongside Windows, you need GRUB to appear at startup so you can pick between them.

Installing GRUB from the Windows 11 command line means you are using the built-in terminal tools to write GRUB to your disk's boot sector — the small reserved area that runs before any operating system loads. This is different from installing GRUB from a Linux live USB, which is the more common route. The command-line method works when you already have Linux installed and need to repair or reinstall the bootloader without rebooting into Linux.

This process carries real risk: a mistake can make your computer unbootable. Back up your important files before you start, and follow each step exactly as written.

Key Takeaways

  • GRUB must be installed from a Linux environment, not from Windows itself — you need a Linux live USB or an existing Linux installation to run the commands.
  • The Windows 11 command line cannot install GRUB directly; you use it only to manage disks and prepare the system before booting into Linux to complete the installation.
  • You must identify your disk device name (like /dev/sda) and your Linux partition before running any GRUB commands, or you risk overwriting the wrong disk.
  • After GRUB installs, restart your computer and you should see a menu at boot time that lets you choose Windows 11 or Linux.

Why you cannot install GRUB from Windows Command Prompt

The Windows 11 Command Prompt and PowerShell are Windows tools. GRUB is a Linux bootloader and requires a Linux environment to install. Windows does not have the libraries, drivers, or permissions needed to write GRUB to your boot sector safely.

If you search for "install GRUB from Windows command line," you will find posts suggesting you use Windows Subsystem for Linux (WSL). WSL is a compatibility layer that runs Linux commands inside Windows, but it does not have access to your actual disk hardware. Any GRUB installation command in WSL will fail or install to a fake disk that has no effect on your real boot process.

The only working path is to boot into an actual Linux environment — either a live USB or an existing Linux partition — and run the GRUB commands from there. If you already have Linux installed, you can open a terminal in Linux and proceed. If you do not, you need to create a bootable Linux USB first.

Creating a bootable Linux USB if you do not have Linux yet

If you are starting from Windows 11 only, download a Linux distribution ISO file — Ubuntu is the most common choice for beginners. Go to ubuntu.com, download the latest LTS (Long Term Support) version, and save the .iso file to your Downloads folder.

Next, you need a USB drive of at least 4 GB and a tool to write the ISO to it. Download Rufus (rufus.ie) or Balena Etcher (balena.io/etcher). Insert your USB drive, open Rufus or Etcher, select the Ubuntu .iso file you downloaded, choose your USB drive from the device list, and click the button to write. This takes a few minutes and will erase everything on the USB drive.

When the write is complete, restart your computer and enter the boot menu. On most Windows 11 machines, hold F12, F2, Delete, or Esc while the computer is starting up — the key varies by manufacturer. Select your USB drive from the boot menu. The computer will start Ubuntu from the USB without installing it, and you will see the Ubuntu desktop.

Identifying your disk and Linux partition from Linux

Once you are running Linux (either from USB or from an existing Linux installation), open a terminal. You can usually find it in the applications menu or press Ctrl+Alt+T.

Type this command and press Enter:

lsblk

This shows all your disks and partitions. You will see output like this:

sda 8:0 0 500G 0 disk├─sda1 8:1 0 512M 0 part /boot/efi├─sda2 8:2 0 16G 0 part [SWAP]├─sda3 8:3 0 100G 0 part /└─sda4 8:4 0 383G 0 part /mnt/windowssdb 8:16 1 16G 0 disk└─sdb1 8:17 1 16G 0 part /media/ubuntu/UBUNTU

In this example, sda is your main hard drive and sdb is the USB drive you booted from. The sda3 partition (marked with /) is your Linux root partition — this is where GRUB will install. The sda1 partition (marked /boot/efi) is your EFI system partition, which GRUB also needs to access.

Write down your disk name (sda, sdb, nvme0n1, etc.) and your Linux partition (sda3, nvme0n1p3, etc.). If you are unsure which is which, look at the size — your main drive is usually the largest, and the USB is usually much smaller.

Installing GRUB to your boot sector

Before you run GRUB commands, mount your Linux partition if it is not already mounted. In the lsblk output above, sda3 shows / in the last column, which means it is already mounted. If your Linux partition does not show a mount point, type:

sudo mount /dev/sda3 /mnt

Replace sda3 with your actual Linux partition name. This makes the partition accessible to the GRUB installer.

Now install GRUB to your disk. Type this command, replacing sda with your actual disk name (not the partition number):

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB /dev/sda

This command tells GRUB to install to the EFI boot sector of your disk. The --efi-directory flag points to your EFI partition. If the command succeeds, you will see a message like "Installation finished. No errors reported."

If you see an error like "Could not prepare Boot variable," your EFI partition may not be mounted. Mount it with:

sudo mount /dev/sda1 /boot/efi

Then run the grub-install command again, replacing sda1 with your actual EFI partition.

Generating the GRUB configuration file

GRUB needs a configuration file that tells it which operating systems are installed and how to start them. Generate this file by typing:

sudo grub-mkconfig -o /boot/grub/grub.cfg

This command scans your disk for Windows and Linux installations and writes a menu file. You should see output like:

Generating grub configuration from /etc/grub.d ...Found linux image: /boot/vmlinuz-5.15.0-56-genericFound Windows Boot Manager on /dev/sda2done

The "Found Windows Boot Manager" line means GRUB detected your Windows 11 installation and will add it to the boot menu. If you do not see this line, Windows may be on a partition GRUB did not scan, but you can still boot it manually from the GRUB menu later.

Restarting and testing the boot menu

Close the terminal and restart your computer. Type:

sudo reboot

When the computer restarts, you should see the GRUB menu before Windows or Linux loads. The menu will show options like "Ubuntu" and "Windows Boot Manager." Use the arrow keys to select one and press Enter to boot it.

If you see the GRUB menu, the installation worked. Test both options to make sure both Windows 11 and Linux start correctly. If you only see Windows or Linux and no menu appears, GRUB may not have installed to the correct location, or your UEFI firmware is not set to boot from GRUB first. Restart the computer, enter the UEFI setup (usually by pressing F2 or Delete during startup), and look for a boot order setting. Move GRUB or Ubuntu to the top of the list.

If you booted from a USB and want to keep using Linux, you will need to install it to your hard drive permanently. The Ubuntu installer will handle GRUB setup automatically during that process.

Troubleshooting common installation problems

Error: "Could not find efi directory" — Your EFI partition is not mounted or is on a different disk. Run lsblk again, find the partition marked /boot/efi, and mount it with sudo mount /dev/sdaX /boot/efi, replacing sdaX with the correct partition.

GRUB menu does not appear at startup — Your UEFI firmware is still set to boot Windows first. Restart, enter UEFI setup, and change the boot order. Look for an entry called "GRUB," "Ubuntu," or "Linux" and move it above "Windows Boot Manager."

Windows does not appear in the GRUB menu — Run sudo grub-mkconfig -o /boot/grub/grub.cfg again. If Windows still does not appear, you can add it manually by editing /etc/grub.d/40_custom with a text editor, but this is advanced. For most users, it is easier to boot Windows from the UEFI firmware menu temporarily and then fix the GRUB configuration later.

Computer will not boot at all — You may have installed GRUB to the wrong disk. If you have a Windows 11 installation USB, boot from it, open Command Prompt, and run bootrec /fixmbr to restore the Windows bootloader. Then try the GRUB installation again, being very careful to use the correct disk name.

Frequently Asked Questions

Can I install GRUB without a Linux USB if I already have Linux on my computer?

Yes. Boot into your existing Linux installation normally, open a terminal, and run the grub-install and grub-mkconfig commands. You do not need a USB. This is actually the safest method because you are working from a fully installed Linux system rather than a live environment.

What if I only want to boot Windows and do not need GRUB?

If you installed Linux by mistake or changed your mind, you can remove GRUB by booting from a Windows 11 installation USB, opening Command Prompt, and running bootrec /fixmbr. This restores the Windows bootloader. Then delete the Linux partitions from Disk Management.

Will GRUB slow down my computer?

No. GRUB runs only at startup to show the menu. Once you select an operating system, GRUB exits and your system boots normally. The menu adds a few seconds to startup time, but you can set a timeout so it automatically boots your default choice if you do not press a key.

Can I uninstall GRUB later if I decide I do not want a dual boot?

Yes. Boot into Windows, open Command Prompt as administrator, and run bootrec /fixmbr. This replaces GRUB with the Windows bootloader. You can then delete the Linux partitions. Your computer will boot Windows only, just as it did before.

What if my computer uses BIOS instead of UEFI?

The commands are slightly different. Instead of grub-install --target=x86_64-efi, use grub-install --target=i386-pc /dev/sda. Most modern Windows 11 computers use UEFI, but if your computer is older, check your UEFI setup screen to confirm which mode you are using.