How to Restore GRUB After Reinstalling Windows
Many of us dual-boot Windows and Linux. A common problem is that reinstalling Windows overwrites the Linux MBR (Master Boot Record). After this, your Linux installation won’t appear as a boot option, and you can’t start it from your hard drive.
No worries, you can fix it using a Live Linux system.
Step 1: Boot from Live Linux
- Use a USB or CD with your Linux installation and boot into the Live system.
- Open a terminal, this is where we’ll run all commands.
Step 2: Mount Your Linux Partition
First, create a root mount directory:
mkdir /mnt/rootNext, find your Linux partition:
sudo fdisk -lYou’ll see output like:
Device Boot Start End Blocks Id System
/dev/sda1 2048 206847 102400 7 LinuxHere /dev/sda1 is your Linux partition.
Now mount it:
sudo mount /dev/sda1 /mnt/rootAlso, mount the proc subsystem and dev:
sudo mount -t proc none /mnt/root/proc sudo mount -o bind /dev /mnt/root/devStep 3: Chroot Into Your Linux System
Use chroot to change the root directory for the terminal to your Linux installation:
sudo chroot /mnt/root /bin/bashNow you are “inside” your Linux system as if it were booted normally.
Step 4: Reinstall GRUB
Depending on your distro:
For Ubuntu / GRUB (legacy):
grub-install /dev/sdaor if you need to specify root directory:
grub-install /dev/sda --root-directory=/mntFor Fedora / GRUB2:
grub2-install /dev/sdaTip: Use
--forceif any errors appear.
Step 5: Update GRUB Configuration
After reinstalling GRUB, update its config so it detects all OSes:
Ubuntu / GRUB:
grub-mkconfig -o /boot/grub/grub.cfgFedora / GRUB2:
grub2-mkconfig -o /boot/grub2/grub.cfgStep 6: Reboot
Exit chroot, unmount partitions if needed, and reboot. Your GRUB menu should now be restored, letting you boot into Linux and Windows again.
