You are not logged in.

#1 2022-10-14 18:43:56

mainpin442
Member
Registered: 2022-10-14
Posts: 1

GRUB not detecting Windows,but os-prober does

Hello everyone,
I had Arch Linux installed for half a year on my computer, with only one drive. A few days ago, I bought a new one and tried to dualboot Arch and Windows. Expecting Windows to cause problems, I downloaded Arch ISO and Windows ISO on my USB using Ventoy.
Despite the fact that I installed Windows on the new drive, GRUB worked the same as before,but it didn't detect Windows, so I modified /etc/default/grub to enable os-prober and then ran sudo grub-mkconfig /boot/efi/grub/grub.cfg. After that I was unable to even access GRUB, and had to boot from USB and follow this guide on fixing the problem. After that, I am again in the same spot now, even after manually removing my drive containing Arch and reinstalling Windows 10 on the other, this time with CSM support disabled (I am using a Gigabyte motherboard, and this is the only thing I can do, I surely hope this is not the issue), and then returning the Arch drive and reinstalling GRUB AGAIN.

Here's all the info:

fdisk -l:

Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 870 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 9259D311-9EE9-440E-9171-492779A6A023

Device          Start        End    Sectors   Size Type
/dev/sda1        2048     206847     204800   100M EFI System
/dev/sda2      206848     239615      32768    16M Microsoft reserved
/dev/sda3      239616 1952462447 1952222832 930.9G Microsoft basic data
/dev/sda4  1952462848 1953521663    1058816   517M Windows recovery environment


Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: KINGSTON SNVS500G                       
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 9C728531-5588-4462-B1E5-901D5E51CC85

Device           Start       End   Sectors   Size Type
/dev/nvme0n1p1    2048   1048575   1046528   511M EFI System
/dev/nvme0n1p2 1050624 976773119 975722496 465.3G Linux filesystem


Disk /dev/zram0: 4 GiB, 4294967296 bytes, 1048576 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

os-prober:

/dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi

cat /etc/grub.d/40_custom (I tried...):

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Windows' {
        search --set=root --file /efi/Microsoft/Boot/bootmgfw.efi
        chainloader /EFI/Microsoft/Boot/boottmgfw.efi
}

cat boot/efi/grub/grub.cfg:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root c1338628-bc8f-4da1-a4ef-8df0a8e80ed6
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-c1338628-bc8f-4da1-a4ef-8df0a8e80ed6' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root B9F6-9BB0
        echo    'Loading Linux linux ...'
        linux   /vmlinuz-linux root=UUID=c1338628-bc8f-4da1-a4ef-8df0a8e80ed6 rw rootfstype=ext4 loglevel=3 quiet
        echo    'Loading initial ramdisk ...'
        initrd  /amd-ucode.img /initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-c1338628-bc8f-4da1-a4ef-8df0a8e80ed6' {
        menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-c1338628-bc8f-4da1-a4ef-8df0a8e80ed6' {
                load_video
                set gfxpayload=keep
                insmod gzio
                insmod part_gpt
                insmod fat
                search --no-floppy --fs-uuid --set=root B9F6-9BB0
                echo    'Loading Linux linux ...'
                linux   /vmlinuz-linux root=UUID=c1338628-bc8f-4da1-a4ef-8df0a8e80ed6 rw rootfstype=ext4 loglevel=3 quiet
                echo    'Loading initial ramdisk ...'
                initrd  /amd-ucode.img /initramfs-linux.img
        }
        menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-c1338628-bc8f-4da1-a4ef-8df0a8e80ed6' {
                load_video
                set gfxpayload=keep
                insmod gzio
                insmod part_gpt
                insmod fat
                search --no-floppy --fs-uuid --set=root B9F6-9BB0
                echo    'Loading Linux linux ...'
                linux   /vmlinuz-linux root=UUID=c1338628-bc8f-4da1-a4ef-8df0a8e80ed6 rw rootfstype=ext4 loglevel=3 quiet
                echo    'Loading initial ramdisk ...'
                initrd  /amd-ucode.img /initramfs-linux-fallback.img
        }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-efi-6E66-76D8' {
        insmod part_gpt
        insmod fat
        set root='hd0,gpt1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1  6E66-76D8
        else
          search --no-floppy --fs-uuid --set=root 6E66-76D8
        fi
        chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
fwsetup --is-supported
if [ "$grub_platform" = "efi" -a "$?" = 0 ]; then
        menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
                fwsetup
        }
fi
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/35_fwupd ###
### END /etc/grub.d/35_fwupd ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Windows' {
        search --fs-uuid --set=root /dev/sda1 19259d311-9ee9-440e-9171-492779a6a023
        chainloader /EFI/Microsoft/Boot/boottmgfw.efi
}
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

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

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  amd-ucode.img initramfs-linux-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done

Any help would be appreciated, thanks in advance.

Last edited by mainpin442 (2022-10-14 18:45:51)

Offline

#2 2022-10-14 19:11:14

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

Re: GRUB not detecting Windows,but os-prober does

You probably have mixed up (new) grub config and (old) runtime files. See here.


sys2064

Offline

#3 2022-10-14 23:31:01

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: GRUB not detecting Windows,but os-prober does

What's the output of efibootmgr?

Exactly what commands did you use when installing grub?

Having two ESPs can cause issues, although my impression is most firmware tolerate them.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB