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!
It looks like you’ve followed an old guide that expects Windows to use MBR partitioning.
The «invalid signature» error suggests Secure Boot is enabled. When Secure Boot is enabled, all bootloaders must be signed with a private key, and a matching public key must be included in the Secure Boot variables in the firmware NVRAM. GRUB is dutifully reading the first sector of the partition you’ve specified, but since it does not contain the appropriate Secure Boot signature, the firmware refuses to execute it.
Secure Boot requires native UEFI-style boot as a prerequisite. You may be able to disable Secure Boot on your system, but since GRUB already starts for you, there is probably no need to do that.
Your insmod part_gpt
suggest you expect the disk to have a GPT-style partitioning which usually goes together with UEFI boot style, but on the other hand, set root=(hd0,msdos2)
expects a MBR partition.
On my Debian system with GPT partitioning, the set root
line reads: set root='hd0,gpt1'
. If your system uses GPT partitioning, use the gptN
partition identifiers instead of msdosN
.
Also chainloader +1
tells GRUB to read the boot block from the first block of the partition; in UEFI native boot, there is no such thing. To boot Windows in UEFI mode, the set root
line should point to the EFI System Partition that contains the Windows bootloader, and the chainloader line should be chainloader /EFI/Microsoft/Boot/bootmgfw.efi
.
It looks like you’ve followed an old guide that expects Windows to use MBR partitioning.
The «invalid signature» error suggests Secure Boot is enabled. When Secure Boot is enabled, all bootloaders must be signed with a private key, and a matching public key must be included in the Secure Boot variables in the firmware NVRAM. GRUB is dutifully reading the first sector of the partition you’ve specified, but since it does not contain the appropriate Secure Boot signature, the firmware refuses to execute it.
Secure Boot requires native UEFI-style boot as a prerequisite. You may be able to disable Secure Boot on your system, but since GRUB already starts for you, there is probably no need to do that.
Your insmod part_gpt
suggest you expect the disk to have a GPT-style partitioning which usually goes together with UEFI boot style, but on the other hand, set root=(hd0,msdos2)
expects a MBR partition.
On my Debian system with GPT partitioning, the set root
line reads: set root='hd0,gpt1'
. If your system uses GPT partitioning, use the gptN
partition identifiers instead of msdosN
.
Also chainloader +1
tells GRUB to read the boot block from the first block of the partition; in UEFI native boot, there is no such thing. To boot Windows in UEFI mode, the set root
line should point to the EFI System Partition that contains the Windows bootloader, and the chainloader line should be chainloader /EFI/Microsoft/Boot/bootmgfw.efi
.
- I have installed Windows 10
- I have installed Linux Mint Silvia and I have chosen a device for boot loader installation — sda.
- There is not Windows 10 in grub menu when the system starts
- I have booted via Linux Mint live USB.
- I Do step by step https://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd
- But it still no Windows 10 in grub menu
- I have booted via live windows 10 USB.
- With restoration tools, I have chosen the command line
- I have fixed Mbr by console command bootrec /FixMbr
- Ok, windows 10 is loading by there is no Grub.
- I have repeated steps 4 and 5
- 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
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
5,6227 gold badges33 silver badges48 bronze badges
answered May 20, 2018 at 7:31
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
9,5612 gold badges22 silver badges40 bronze badges
answered Apr 15, 2019 at 6:33
1
Как добавить пункт загрузки Windows 7 в Grub2 ?
В этом мне помогли вот эти источники:
http://habrahabr.ru/qa/3772
http://ask.fedoraproject.org/question/136/how-to-update-grub2-on-fedora-16
http://ru.wikibooks.org/wiki/Grub_2
Как-то, сидя грустным вечером за компом, мне захотелось поиграть во что-нибудь. Но тут я вспомнил, что после того, как поставил на новый винт свеженькую Fedora 17, я так и не удосужился в загрузчик добавить пунт загрузки для винды. Винда 7 у меня стоит на отдельном жёстком диске, чтобы иногда поиграть. И лишь для этого, бо для остального есть линух и виртуальные машины.
Всё бы ничего, но в новой федоре и загрузчик тоже новый. Поэтому пришлось чуток погуглить. Для начала, нужно узнать обозначение диска, на котором стоит винда. В моём случае, это был диск sdd (4-ый жёсткий диск на компе). Затем, надо узнать номер раздела, с которого грузится винда. Обычно, если винда установлена штатно, то в ней есть так называемый раздел «Зарезервировано системой». В линухе же он у меня имел обозначение sdd1. Нам понадобится узнать uuid этого раздела. Делаем команду:
ls -al /dev/disk/by-uuid
И у себя я вижу вот такой вывод:
.................
lrwxrwxrwx. 1 root root 10 июля 28 21:49 82FE2760FE274BAB -> ../../sdd1
.................
Всё, теперь есть вся нужная информация, чтобы создать дополнительный пункт загрузки в grub2. Находим файл /etc/grub.d/40_custom и в его конец добавляем вот такую конструкцию:
menuentry "Win7" { insmod part_msdos insmod ntfs set root='(hd3,msdos2)' search --no-floppy --fs-uuid --set 82FE2760FE274BAB chainloader +1 }
Где hd3 — это диск sdd (четвёртый). Именно так, бо в грубе исчисление дисков начинается с нуля: hd0, hd1, hd2 и т.д. Ну и uuid сами видите, где нужно было вставить.
После редактирования вышеназванного файла делаем команду:
grub2-mkconfig -o /boot/grub2/grub.cfg
И перезагружаем комп. Загружаемся под виндой и шпилим в игрухи на здоровье!
You have no rights to post comments