4

My issues started when I partitioned my Ubuntu 22.04 LTS drive to add Windows 11 (I used my Ubuntu bootable to partition the drive).

Once Windows 11 was installed, my computer began to boot Windows 11 instead of showing me the grub menu. I fixed this by entering the BIOS and moving Ubuntu to the top. My computer was booting into Ubuntu now, but I still wasn't seeing the grub menu.

After looking at this post, Why is Grub menu not shown when starting my computer?, I was able to get my grub menu to show again (@Akalgnotum). But Windows 11 was not included in the menu.

With the guidance of this post, GRUB does not detect Windows I ran: sudo os-prober which returned /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi. I then ran sudo update-grub which gave me this "warning":

Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-46-generic
Found initrd image: /boot/initrd.img-5.15.0-46-generic
Found linux image: /boot/vmlinuz-5.15.0-43-generic
Found initrd image: /boot/initrd.img-5.15.0-43-generic
Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

From what I gather, Windows won't be added by sudo update-grub because it won't run and use the information given by os-prober.

I have no idea how to fix this. Any suggestions would be extremely helpful. If more information is needed, I'll be happy to provide it.

Thanks!

Pranai Rao
  • 401
  • 1
  • 4
  • 12
  • 1
    @Rinzwind as per the warning given, the issue appears to be that grub is not running os-prober because it was disabled in the config file – Esther Aug 25 '22 at 14:03
  • 1
    @Esther I concur that is the issue, however I am not sure how to fix it. After some more digging, I found a solution (that worked for me) which I have posted below. If you know how to fix the os-prober issue, that would be helpful to posterity. – Pranai Rao Aug 25 '22 at 14:50

5 Answers5

13

After digging through the internet for days, I found an answer!

All credit goes to this post: https://askubuntu.com/a/977251/1191399. I am just reiterating it.

  1. sudo fdisk -l

You should get a long return that includes something like this:

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624  874729471 873678848 416.6G Linux filesystem
/dev/nvme0n1p3 874729472  874762239     32768    16M Microsoft reserved
/dev/nvme0n1p4 874762240 1000214527 125452288  59.8G Microsoft basic data
  1. Get the UUID of the EFI partition sudo blkid /dev/nvme0n1p1 (replace nvme0n1p1 with the correct partition for you)

Return: dev/nvme0n1p1: UUID="3C26-6A4C" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="3b64b43f-e7eb-4ac8-a32c-9af2edf64d0d"

  1. Grant yourself write permission to the '40_custom' file in /etc/grub.d

    Open the terminal (ctrl+alt+t) and run the following commands:
    cd /etc/grub.d
    sudo chmod o+w 40_custom

  2. Open the 40_custom file
    open ./40_custom

  3. Write the following at the bottom of the file and replace 3C26-6A4C with the correct UUID:

menuentry 'Windows 11' {
    search --fs-uuid --no-floppy --set=root 3C26-6A4C
    chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
  1. Save the file and close the editor.

  2. Back in the terminal, remove write permissions.
    sudo chmod o-w 40_custom

  3. Update GRUB using sudo update-grub

  4. (Optional) You can confirm that your change was successful by going to /boot/grub/grub.cfg and checking lines 243-251. It should reflect your edits in the 40_custom file

  5. Reboot your computer reboot

Pranai Rao
  • 401
  • 1
  • 4
  • 12
  • 1
    Your solution involving the GRUB configuration was an absolute lifesaver and allowed me to successfully set up dual booting with Windows 11. It saved me a tremendous amount of time as my Windows UEFI system partition was deleted I was not able to dual boot from Windows. – Akash Amar Oct 28 '23 at 19:31
  • Thanks for this answer. It works. But where does the string /EFI/Microsoft/Boot/bootmgfw.efi come from? How can one mount/explore/findout what's inside of this Microsoft reserved partition? – kcbehler Feb 24 '24 at 11:04
5

Grub 2.06 turns off os-prober in /etc/default/grub.

https://www.phoronix.com/news/Ubuntu-22.04-Multi-Boot-Changes

There is some sort of security issue with it scanning all the partitions looking for other systems. You can turn on/off in /etc/default/grub.

Best to just run once, and then copy Windows boot stanza into 40_custom. Also then makes all future updates faster especially if you have lots of partitions to scan.

sudoedit /etc/default/grub

Then change to true/false as required. True recommended.

GRUB_DISABLE_OS_PROBER=true

You can easily copy a boot stanza to 40_custom.

One way to fix the descriptions is to move the windows entries to 40_custom and edit at will.

Copy the entries from this:

sudo cp -a /boot/grub/grub.cfg /boot/grub/grub.cfg.backup
sudoedit /boot/grub/grub.cfg

Copy them to and edit to have only entries you want:

sudoedit /etc/grub.d/40_custom

After any changes to grub or grub's scripts, you have to update grub menu.

sudo update-grub

Grub menu with Windows 10 and Ubuntu 14.04

Typical UEFI Windows boot stanza as generalted by os-prober. Each ESP - has unique UUID and partUUID. the UUID in boot stanza is the UUID of your ESP.

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-F8FD-D8E5' {
    insmod part_gpt
    insmod fat
    search --no-floppy --fs-uuid --set=root F8FD-D8E5
    chainloader /efi/Microsoft/Boot/bootmgfw.efi
}

If using above stanza, you must update to your UUID and no need for the comment on using os-prober. To see UUID of ESP.

lsblk -f

Note: Grub only boots working Windows. And UEFI Secure Boot must be off. Windows often turns Windows fast start up back on with updates. So then you have to directly boot Windows using UEFI one time boot key,often f12 but varies by vendor.

oldfred
  • 12,100
  • I wasn't aware that os-prober was disabled due to security issues in update-grub. I agree, it seems that the best method henceforth would be to use the 40_custom file to make a custom entry for Windows. I posted my method below. There seems to be a lot of variation in the syntax for making the custom entry, but the one in my post is the only one that worked for me (changing the UUID of course). – Pranai Rao Aug 25 '22 at 15:04
1

1. List disks & partitions

lsblk

2. Identify the disk containing your windows partition.

sudo cfdisk /dev/sd<YOUR DISK LETTER (NO NUMBER)>
  • Use the vertical arrow keys to cycle through your devices.
  • The EFI partition will be the device typed as "EFI System".
  • Copy the "Filesystem UUID" for your EFI device. (XXXX-XXXX)
  • Select [ Quit ] using your keyboard's arrow keys. Press enter to quit cfdisk.

3. Open /etc/grub.d/40_custom in your favorite editor (nano, vim, code)

sudo nano /etc/grub.d/40_custom

4. Append your menu entry below the comment.

menuentry 'Windows 11' {
    search --fs-uuid --no-floppy --set=root <YOUR "File system UUID">
    chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}

5. Update your grub config.

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

Finish with sudo reboot

dubble
  • 11
0

Use OS-prober. In the latest grub you have to write a few lines to change that.

What file to edit?

You need to edit the Grub configuration file which is located on:

sudo nano /etc/default/grub

Make sure that you are a root or root privileged user who can edit.

What to edit?

To disable the OS Prober, use the following command.

GRUB_DISABLE_OS_PROBER=true

To enable the OS Prober, use the following command.

GRUB_DISABLE_OS_PROBER=false

Once you have set the instruction you can save and exit the file.

Now just update the Grub so it can take effects.

sudo update-grub

This is it, just reboot (restart) the system and check it.

Or follow this " https://www.atulhost.com/how-to-disable-or-enable-os-prober-from-the-grub "

It Should look like this

GRUB_DEFAULT=2

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

GRUB_CMDLINE_LINUX=""

GRUB_DISABLE_OS_PROBER=false

  • OS-prober seems to no longer be recommended by Ubuntu. I believe it is being deprecated but I could be wrong. – Pranai Rao Dec 01 '22 at 15:40
0

At least for me, this is what solved it. os-prober was disabled. I am on Ubuntu 22.04

sudo nano /etc/default/grub

Set GRUB_DISABLE_OS_PROBER=false

Then run

sudo update-grub