Add windows to grub2

I had to install Ubuntu 18.04 after Windows. I lost Windows from grub. I used" Boot Recovery " to return the hornbeam to the Root of /dev/sda. Then, using grub customize, I added Windows. Outputs this error.

enuentry "Windows 8" { 
insmod part_gpt 
insmod chain set root='(hd0,gpt2)' 
chainloader /EFI/microsoft/BOOT/bootmgfw.efi 
}

Help create the correct setup. Windows is located in /dev/sda2 (Drive C).

Author: aleksandr barakin, 2018-10-23

1 answers

In most cases, manual editing of the grub2 config (grub.cfg) is redundant and counterproductive - this file is generated by a special script. Also, the same script is run automatically, for example, when updating the kernel. Among other things, this script finds the installed operating systems using the os-prober utility.

The specific name and how to run the script varies from distribution to distribution, but developers almost always leave a hint in the header of the file /etc/default/grub, for example on debian:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

Thus, when starting update-grub (from root, of course), it must find all the installed OS and win itself.

 2
Author: Fat-Zer, 2018-10-23 16:03:43