Добавление загрузки windows в grub

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: Установка Windows на диск с Linux
  • Способ 2: Обнаружение раздела Windows
  • Способ 3: Ручное добавление загрузчика
  • Вопросы и ответы

grub не видит Windows 10

Способ 1: Установка Windows на диск с Linux

Одной из наиболее распространенных причин отсутствия Windows 10 в загрузочном меню «Grub» является установка Windows не на тот же физический диск, на который устанавливается Linux. Если нужно установить на один компьютер Windows и Linux, устанавливайте их по возможности на один физический жесткий диск, причем первой необходимо установить Windows. Если сперва будет установлена Linux, а затем Windows, то есть большая вероятность, что загрузчик Windows затрет «Grub».

Если переустановка Windows 10 по какой-то причине невозможна, попробуйте обнаружить ее из среды Linux и добавить в загрузчик последней.

  1. Определите в Linux название раздела, на который установлена Windows. Получить сведения о дисках и разделах в Linux можно как из «Терминала», так и с помощью штатного приложения «Дисковая утилита». Скопируйте или запомните название устройства. Например, это будет «/dev/sda1».
  2. grub не видит Windows 10.1

  3. Откройте «Терминал» и примонтируйте раздел с Windows 10, для чего выполните команду sudo mount -t ntfs-3g -o ro /dev/sda1, где /dev/sda1 — полученный на предыдущем этапе путь к тому с Windows.
  4. Чтобы обнаружить Windows 10, выполните тут же в «Терминале» команду sudo os-prober.
  5. grub не видит Windows 10.2

  6. В случае успешного обнаружения Windows обновите конфигурацию «Grub» командой sudo update-grub либо же sudo grub2-mkconfig -o /boot/grub/grub.cfg.
  7. grub не видит Windows 10.3

Способ 3: Ручное добавление загрузчика

При использовании первого способа вероятность сходу обнаружить и прописать Windows 10 в линуксовый загрузчик довольно невелика. Более сложным, но и более эффективным способом восстановления записи Windows 10 в загрузочном меню Grub является ручное добавление. Способ универсальный, использовать его можно не только при потере Windows 10, но и других операционных систем Windows.

  1. Узнайте название раздела с Windows как было показано в первом пункте предыдущего способа.
  2. Определите UUID раздела, на котором установлена Windows 10, для чего выполните в «Терминале» команду blkid /dev/sda1, где /dev/sda1 — название раздела с Windows.
  3. grub не видит Windows 10.4

  4. Откройте любым текстовым редактором файл /etc/grub.d/40_custom и вставьте в него следующий код, где XXXXXXXXXXXXXXXX — полученный на предыдущем шаге UUID:

    menuentry "Windows 10" {
    insmod ntfs
    set root='(hd0,1)'
    search --no-floppy --fs-uuid --set XXXXXXXXXXXXXXXX
    chainloader +1
    }
    .
    Сохраните файл.

  5. grub не видит Windows 10.5

  6. Обновите конфигурацию Grub командой sudo update-grub, перезагрузите компьютер и посмотрите, появилась ли Windows в загрузочном меню Grub.

Если восстановить/добавить запись Windows 10 в загрузочное меню «Grub» не удалось, проверьте, не удален ли на диске служебный 100 МБ NTFS-раздел с загрузочными файлами. Если удален, можно будет попробовать его восстановить, но будет гораздо проще переустановить Windows и Linux. В том случае, когда используется «Grub 2» на UEFI, попробуйте включить в BIOS режим «Legacy».

Еще статьи по данной теме:

Помогла ли Вам статья?

  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.

У меня есть жесткий диск, на котором установлена Windows. Я попробовал установить Fedora на новый жесткий диск.
Теперь я могу выбирать в Bios диск, с которого будет происходить загрузка и таким образом загружать Windows или Fedora. Однако, хотелось бы увидеть в загрузчике сразу 2 ОС и выбирать между ними.

Я пробовал делать так:

grub2-mkconfig -o /boot/grub2/grub.cfg

Однако Windows не определяется. Вывод выглядит так:

[root@localhost default]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.13.9-300.fc27.x86_64
Found initrd image: /boot/initramfs-4.13.9-300.fc27.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-45450d3854b84d8ba40c055b725c1f51
Found initrd image: /boot/initramfs-0-rescue-45450d3854b84d8ba40c055b725c1f51.img
done

Что я делаю не так и как мне добавить выбор двух ОС в загрузчик?

UPD:

Fedora грузится в EFI, а Windows в Legacy

Updating GRUB via the Terminal may be the fastest solution

by Afam Onyimadu

Afam is a geek and the go-to among his peers for computer solutions. He has a wealth of experience with Windows operating systems, dating back to his introduction… read more


Updated on

  • GRUB allows users to choose between operating systems installed on their computers at startup.
  • You may update GRUB to force it to notice newly added OS like Windows 11. 

XINSTALL BY CLICKING THE DOWNLOAD
FILE

GRUB (GRand Unified Bootloader) is the bootloader that allows you to choose between different operating systems installed on your computer when you start it up. It provides a menu that lists all the available operating systems, and you can select the one you want to boot into.

However, when you install a new operating system, it may not appear in the GRUB menu. This can happen if the new operating system wasn’t set up to work with GRUB during installation or the bootloader was overwritten.

This article will explain why GRUB may not show Windows 11 and how you can add it to the GRUB menu in just a few steps.

Why is GRUB not showing Windows 11?

There are a few different reasons why Windows 11 may not be showing up in the GRUB menu.

  • Incomplete installation – One possibility is that the installation or boot process did not correctly set up Windows 11 to work with GRUB. This can happen if the installer does not detect the other operating systems on the computer.
  • Overwriting during installation – This can happen if the user chooses to install Windows 11 in the same partition as an existing operating system or if the user chooses to install Windows 11 to the same drive as the bootloader.

Note that there are different related issues users have faced, including GRUB rescue, deleted GRUB,

If Windows 11 is not showing up in the GRUB menu, you can add it by editing the GRUB configuration file and adding an entry for Windows 11. Below we outline the steps you must take.

1. Update GRUB

  1. Boot into an operating system that is already listed in the GRUB menu.
  2. Press Ctrl + Alt + T to launch the Terminal.
  3. Lastly, enter the script below:
    sudo update-grub
    add windows 11 to grub

This will update the GRUB configuration file and scan all partitions on your hard drive to detect operating systems that aren’t listed in the GRUB menu.

2. Manually add a GRUB entry

  1. Press Ctrl + Alt + T to launch the Terminal.
  2. Enter the script below to open the GRUB configuration file:
    sudo nano /etc/grub.d/40_custom
    add windows 11 to grub
  3. Now, paste the below lines of code at the end of the file (ensure to replace hdx,y with the partition where Windows 11 is installed):
    menuentry "Windows 11" {
    set root=(hdx,y)
    chainloader +1
    ntldr /bootmgr
    }
  4. Press Ctrl + X, then Y to save the changes made.
  5. Again, the script below to apply your changes:
    sudo update-grub
  6. Finally, restart the computer.
Read more about this topic

  • How to Type Accents on Windows 11
  • How to Disable the Insert Your Security Key Into the USB Port popup
  • DTS Sound Unbound for Windows 11: Download & Install
  • How to Remove Windows Copilot on Windows 11

It is important to note that some details may vary depending on your specific system configuration. However, back up your current GRUB configuration before making any changes. Also, select the proper partition and drive to avoid boot problems.

Let us know in the comments below what worked for you.

newsletter icon

  • Добавить сканер kyocera в windows 10
  • Добавление переменной среды windows 10
  • Добавление драйверов принтера в windows
  • Добавление места на диск с windows 10
  • Добавление сетевого расположения windows 10