How to add windows 10 to grub

I recently got a computer from school. It came with Windows 8.1 installed. I then installed another copy of Windows 8.1 (so it would use the built-in Windows Pro license) and upgraded it to Windows...

Windows 10 will, for the most part, be added to grub boot menu by the os-prober automajically.

For my specific setup I wanted to completely hide grub menu and automatically boot windows unless a hotkey was pressed to boot Ubuntu. So in my specific case os-prober isn’t an option because the most important step in hiding the grub menu, which most answers I found neglect to mention, is to set the disable os-prober flag or the menu WILL be shown until os-prober completes.

It took considerably longer than I had anticipated to get right because there are so many partial answers out there but most are version dependant and can lead you astray. I spent a lot of time trying write my own grub menu entry trying use grub commands that didn’t exist like ntdlr. Another caveat is that the chainloader functions on my grub try to boot bios not efi and will not work.(Im sure I was doing something wrong?)

In the end the solution was actually simple as the scripts that make your /boot/grub/grub.cfg do most of the work for you in finding UUIDS for your boot partitions. So you can skip the fdisk and blkid steps most people mention.

So step 1 is to make sure /boot/grub/grub.cfg is current using update-grub to make .cfg file. In terminal

sudo update-grub

Step 2 is to add custom menu entries in /etc/grub.d/40_custom. Don’t waste time trying to write your own simply open /boot/grub/grub.cfg search «menuentry» and copy the automatically generated entries.

The first in the list will be ubuntu mine looks like

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9e66eed6-e672-49ff-a07c-afdc00809148' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  9e66eed6-e672-49ff-a07c-afdc00809148
else
  search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
fi
linux   /boot/vmlinuz-5.4.0-39-generic root=UUID=9e66eed6-e672-49ff-a07c-afdc00809148 ro  quiet splash $vt_handoff
initrd  /boot/initrd.img-5.4.0-39-generic

}

Windows will be similar. Copy both to /etc/grub.d/40_custom. The only change I made for Ubuntu is to add the —hotkey=key flag which will make grub boot the os associated with that hotkey.

menuentry 'Ubuntu2' --class ubuntu --class gnu-linux --class gnu --class os --hotkey=u $menuentry_id_option 'gnulinux-simple-9e66eed6-e672-49ff-a07c-afdc00809148' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  9e66eed6-e672-49ff-a07c-afdc00809148
else
  search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
fi
linux   /boot/vmlinuz-5.4.0-39-generic root=UUID=9e66eed6-e672-49ff-a07c-afdc00809148 ro  quiet splash $vt_handoff
initrd  /boot/initrd.img-5.4.0-39-generic

}

I use —hotkey=u here to set Ubuntu boot hotkey to u.

Then I tweaked the Windows entry, replacing $menuentry_id_option withe the grub —id flag.

menuentry "Windows 10" --class windows --class os --id windows-custom {
insmod part_gpt
insmod fat
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  0EAE-C882
else
  search --no-floppy --fs-uuid --set=root 0EAE-C882
fi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi

}

I used —id windows-custom. Save chages to /etc/grub.d/40_custom.

Finally open /etc/default/grub and add

GRUB_DISABLE_OS_PROBER=true

change GRUB_DEFAULT=0 to GRUB_DEFAULT=windows-custom
and change GRUB_TIMEOUT=10 to your choice of timings I use 0.5 just to give myself a little extra time to hit u to boot Ubuntu after POST.

Hopefully this saves someone a bit of headache, cheers!

  1. I have installed Windows 10
  2. I have installed Linux Mint Silvia and I have chosen a device for boot loader installation — sda.
  3. There is not Windows 10 in grub menu when the system starts
  4. I have booted via Linux Mint live USB.
  5. I Do step by step https://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd
  6. But it still no Windows 10 in grub menu
  7. I have booted via live windows 10 USB.
  8. With restoration tools, I have chosen the command line
  9. I have fixed Mbr by console command bootrec /FixMbr
  10. Ok, windows 10 is loading by there is no Grub.
  11. I have repeated steps 4 and 5
  12. There is no result

Also, I have tried to change grub config with this answer
https://askubuntu.com/questions/661947/add-windows-10-to-grub-os-list#answer-977251 — But in this case, There is Windows 10 — but when I chose — I will recursively going to grub

And with this answer
https://askubuntu.com/questions/661947/add-windows-10-to-grub-os-list#answer-890562
I have an error message when chose Windows 10 — There is no bootmgr directory

Thanks @Kinnectus for help

Also, I have tried

sudo os-prober

And getting

/dev/sda1:FreeDOS:FreeDOS:chain
/dev/sda2:FreeDOS:FreeDOS1:chain

And then I have tried

sudo update-grub

And getting

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.10.0-38-generic
Found initrd image: /boot/initrd.img-4.10.0-38-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found FreeDOS on /dev/sda1
Found FreeDOS on /dev/sda2
done

Unfortunately — there is not Windows 10 in grub menu

Also, I have fdisk output.

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048  16779263  16777216     8G  c W95 FAT32 (LBA)
/dev/sda2  *     16779264  33556479  16777216     8G  c W95 FAT32 (LBA)
/dev/sda3        33556480 770219115 736662636 351,3G  7 HPFS/NTFS/exFAT
/dev/sda4       770220030 976771071 206551042  98,5G  5 Extended
/dev/sda5       770220032 976771071 206551040  98,5G 83 Linux

Partition 4 does not start on physical sector boundary.

There is an issue.
Maybe the problem is with this issue?

Please, help me, I am stucking with this a whole day.
I completely have no idea, what am I doing wrong.

I just installed Arch Linux and with GRUB and want to add my windows 10 with EFI partition to grub.

Now I have Arch installed on the hard drive /dev/sdc/ with a EFI system on /dev/sdc1. On an other hard drive I have Windows 10 installed where the efi drive is /dev/sda1 .

I tried to follow the arch wiki but could not find out were to get the EFI system partition for the command esp/EFI/Microsoft/Boot/bootmgfw.efi. Do I have to mount the windows 10 drive if yes where should I mount it to?

asked Mar 19, 2018 at 21:00

A.Dumas's user avatar

Get the UUID with: sudo grub-probe -t fs_uuid -d /dev/sda1

and then add an entry for Windows at the end of your grub.cfg:

menuentry "Windows 10" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --no-floppy --set=root XXXXXXXXX
chainloader (${root})/efi/Microsoft/Boot/bootmgfw.efi
}

Prvt_Yadav's user avatar

Prvt_Yadav

5,6227 gold badges33 silver badges47 bronze badges

answered May 20, 2018 at 7:31

Mark Roi's user avatar

Mark RoiMark Roi

1641 silver badge11 bronze badges

Normally grub-mkconfig should auto-detect dual booted operating systems (via the os-prober utility). This, however, requires you to have the Windows drive mounted. For example, try this:

$ mkdir -p /mnt/windows
$ mount /dev/sda1 /mnt/windows
$ grub-mkconfig -o /boot/grub/grub.cfg

It should now automatically detect your Windows installation and you should be able to boot into Windows.

Another important thing to note regarding the previous answer to this question: you should never manually edit /boot/grub/grub.cfg, since it can easily be overwritten by tools like grub-mkconfig (and the syntax isn’t really all that intuitive either way).

fra-san's user avatar

fra-san

9,5512 gold badges22 silver badges40 bronze badges

answered Apr 15, 2019 at 6:33

Christoph Böhmwalder's user avatar

1

Skip to content

After a recent malware attack in my Windows 10 PC, I was unable to use it for many days. So this time I decided to install both Windows 10 and Ubuntu 16.04.3 in the dual boot configuration, so that if Windows fails to boot, I can still access all my files using the Ubuntu. And of course, you can always use the powerful Ubuntu Linux on the same PC any time you want. But after installing Ubuntu 16.04.3 on the Windows 10 PC, I found no way to use Windows 10 as the Ubuntu setup somehow failed to add the Windows entry to the Grub menu.

If you are also experiencing a similar problem then you can quickly fix this problem using just two commands. Here is how:

  1. Boot into Ubuntu (well, there is no other option at the moment but to boot into Ubuntu).
  2. Press Ctrl + Alt + T to open the terminal window.
  3. In the terminal window type the following command: sudo os-prober and press Enter.Add Windows to Grub Menu
  4. If you see it detect Windows 10 then all you have to do is type the command sudo update-grub and press Enter. It will add new entries to the grub menu and update it. Now you can reboot your PC and you will see options to boot into Windows.

However, if you do not see the Windows 10 detected after issuing the sudo os-prober command, then you will have to use some extra steps. We have already posted about boot-repair utility that can be used from within Linux to fix most of the boot problems. You can read more about the boot-repair utility from how to restore Ubuntu Linux after re-installing Windows. This tool should be enough to fix the problems and you will never need any of the commands to be used manually or to edit the grub menu by yourself.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.

If you install Ubuntu first and Windows later, you’ll notice that it’s not possible to boot into Linux anymore. As Windows boot loader doesn’t really handle Linux, you’ll need to tell Windows to use Grub.

Once you’re in command prompt with administrative privileges, you can execute:

CMD

bcdedit /set {bootmgr} path EFIUbuntugrubx64.efi

After reboot Grub will show it’s ugly face and you’ll have another problem — there are no Windows entries.

To get them into Grub menu, one can simply update grub:

Terminal

sudo update-grub

On most Linux distributions this will trigger OS Prober and Windows Boot Manager entry will magically appear. However, if you have OS Prober disabled or you want to disable it in future for some reason, you can add manual entry too:

Terminal

cat << EOF | sudo tee /etc/grub.d/25_windows
#!/bin/sh
exec tail -n +3 $0
menuentry 'Windows 10' {
savedefault
search --no-floppy --set=root --file /EFI/Microsoft/Boot/bootmgfw.efi
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
EOF

sudo chmod +x /etc/grub.d/25_windows

sudo update-grub

In either case, boot menu should now offer you option to get into Windows.

Arch Linux installation (Windows 10 dual boot)

Before

  1. Disable Windows Fast-Startup
  2. Disable Secure Boot

Partitioning

Windows 10 Efi partitioning

Partition Location Size File system
Recovery sda1 500 MB ntfs
ESP sda2 100 MB vfat
Reserved sda3 16 MB ?
Windows 10 sda4 80 GB ntfs

Connect to the internet (Wi-Fi)

# wifi-menu
# ping  -c 3 www.google.com

Format and mount disks

# mkfs.ext4 /dev/sdb1
# mkfs.ext4 /dev/sdb2
# mount /dev/sdb2 /mnt
# mkdir /mnt/boot
# mkdir /mnt/home
# mount /dev/sdb1 /mnt/boot
# mount /dev/sdb3 /mnt/home

Install

# pacstrap /mnt base base-devel

Generate fstab

# genfstab -U /mnt >> /mnt/etc/fstab

Chroot and configure base system

# arch-chroot /mnt

Timezone

# ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

Hardware clock

# hwclock --systohc

Locale

# nano /etc/locale.gen

uncomment en_US.UTF-8

# locale-gen
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8

Hostname

# echo arch >> /etc/hostname
# nano /etc/hosts

/etc/hosts should look like:

127.0.0.1   localhost.localdomain   localhost 
::1         localhost.localdomain   localhost
127.0.1.1   arch.localdomain        arch 

Root password

# passwd

Initial ramdisk environment

$ mkinitcpio -p linux

Systemd-Boot

# bootctl --path=/boot install

Then add following content to /boot/loader/entries/arch.conf

tittle    Arch
linux     /vmlinuz-linux
initrd    /initramfs-linux.img
initrd    /intel-ucode.img
options   root=/dev/sda6 rw

and following content to /boot/loader/loader.conf

timeout 5
default arch

GRUB

$ pacman -S dosfstools grub efibootmgr intel-ucode
$ mkdir /boot/efi
$ mount /dev/sda1 /boot/efi

Edit /etc/default/grub, set DEFAULT_TIMEOUT=30.

$ grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck
$ grub-mkconfig -o boot/grub/grub.cfg

Now, let’s add Windows to the GRUB menu. Edit /boot/grub/grub.cfg and add the following menuentry after the Arch Linux menuentries:

menuentry "Windows 10" --class windows --class os {
    insmod part_gpt
    insmod fat
    insmod search_fs_uuid
    insmod chain
    search --fs-uuid --set=root $hints_string $fs_uuid
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

Now change:

  • $hints_string by the output of $ grub-probe --target=fs_uuid /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi

  • $fs_uuid by the output of $ grub-probe --target=hints_string /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi

Network configuration (Wi-Fi)

# pacman -S iw wpa_supplicant dialog networkmanager

Other

# pacman -S zsh reflector ntfs-3g

Unmount and reboot

$ exit      # If still on arch-chroot mode
$ umount -R /mnt
$ reboot

References

Installation

  • Arch Linux Wiki: Beginners Guide
  • Arch Linux Wiki: GRUB
  • Arch Linux Wiki: Installation
  • Arch Linux Wiki: Windows and Arch dual boot

Like this post? Please share to your friends:
  • How to add system windows forms
  • How to add russian language to windows 10
  • How to add python to path windows
  • How to add psql to path windows
  • How to add path to path variable in windows