1

Repair grub after Installing Windows on Preinstalled Ubuntu

 1 year ago
source link: https://www.laravelcode.com/post/repair-grub-after-installing-windows-on-preinstalled-ubuntu
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Repair grub after Installing Windows on Preinstalled Ubuntu

  254 views

  5 months ago

Ubuntu

You might want to use Windows and Ubuntu OS system in one machine. In this progress, when you install Windows, it might happen that when you start the system, Windows straight starts without asking which OS to run.

This happens because when you install Windows OS, it replaces grub with windows boot loader. To fix this issue, you have to do is replace the Windows boot loader with GRUB.

In this article, We will go step-by-step how to replace how to replace the Windows boot loader with GRUB. This can be fixed by command line as well as GUI tool.

Method 1: Command line

Folow the below steps to fix with command line.

Step 1

Boot Ubuntu from live CD or USB stick, select "Try Ubuntu" option.

Step 2

Now you need to find partition number of your main partition. You can check with command sudo fdisk -l Or sudo blkid Or you can use GParted application, which is preinstalled in Ubuntu. In most cases this should be /dev/sda2 but make sure you got correct partition number.

Step 3

Now mount your partition with below command.

sudo mount /dev/sda2 /mnt

If you have a separate /boot, /var or /usr partitions, mount all these partitions to /mnt/boot, /mnt/var and /mnt/usr respectively. For example,

sudo mount /dev/sdaX /mnt/boot
sudo mount /dev/sdaY /mnt/var
sudo mount /dev/sdaZ /mnt/usr

Where sdaX, sdaY, and sdaZ are partition number you find in step 2.

Step 4

Bind mount some other necessary stuff:

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

Step 5

If Ubuntu is installed in EFI mode, use sudo fdisk -l | grep -i efi or GParted to find your EFI partition. It will have a label of EFI. Mount this partition, replacing sdaX with the actual partition number for your system:

sudo mount /dev/sdaX /mnt/boot/efi

Step 6

chroot into your Ubuntu install with below command:

sudo chroot /mnt

Step 7

Now Update grub with below command. You're already running as root.

update-grub

If you get errors or didn't fix your problem, ignore it.

Step 8

If Ubuntu is installed in EFI mode and EFI partition UUID has changed, you may need to update it in /etc/fstab. Compare it:

blkid | grep -i efi
grep -i efi /etc/fstab

If current EFI partition UUID (from blkid) differs from the one in /etc/fstab, update /etc/fstab with current UUID.

Step 9

If everything worked without errors, then you're all set:

exit
sudo reboot

At this point, you should be able to boot normally. If this method didn't fix, you can use the below Boot Repair application.

Method 2: Boot Repair application

There is also GUI Boot Repair tool available to repair grub.

Boot Ubuntu from live CD or USB stick, run "Try Ubuntu" option.

Open the terminal and run the following commands to install Boot Repair.

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

Now open Boot Repair and select Recommended Repair option.

how-to-repair-grub-after-installing-windows-boot-repair.png

When repair is finished, then reboot and check if you recovered access to your OSs.

Here is the oficial website, you can also change from advance option.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK