Bug 2064751

Summary: grub2-mkconfig doesn't detect windows installation on the same drive
Product: [Fedora] Fedora Reporter: Andreas Huppert <a.hup>
Component: os-proberAssignee: Hedayat Vatankhah <hedayatv>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 35CC: agk, hedayatv
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-29 20:09:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
os-prober logfile
none
os-prober logfile with set -e -x
none
tree command output on partition p1
none
tree command output on the referred ACER-Aspire
none
tree command output on partition p1 none

Description Andreas Huppert 2022-03-16 13:30:17 UTC
Description of problem:
After installing Fedora-35 the earlier installed WIN-10 system is not present in the grub2 menu and there is no way to start it. It is no more accessable.


Version-Release number of selected component (if applicable):


How reproducible:
os-prober or grub2-mkconfig



Steps to Reproduce:
1. Install WIN-10 to a brandnew (Samsung EVO 970 Plus SSD) drive: It takes the whole capacity of the drive.
2. Shrink the Windows partition to get place for the Fedora installation
using gparted and check if still Windows works. (It works.)
3. Install Fedora-35.

Actual results:
Windows disappears: It is not listed in the BOOT-menu.


Expected results:
Boot-menu should be complete: Fedora + Windows-boot-manager


Additional info:
Motherboard: MSI B560M-A Pro
BIOS turned to CSM instead of UEFI because old graphic card used.
Maybe this is a duplicate of the newly reported bug on os-prober.

Comment 1 Andreas Huppert 2022-03-16 13:36:18 UTC
See also the Bug 1954472.

Comment 2 Andreas Huppert 2022-03-16 17:29:07 UTC
[root@fedora ~]# fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 970 EVO Plus 1TB            
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: A8073CEB-CAE2-4998-8DCB-69D6E7B29A1B

Device              Start        End   Sectors   Size Type
/dev/nvme0n1p1       2048     206847    204800   100M EFI System
/dev/nvme0n1p2     206848     239615     32768    16M Microsoft reserved
/dev/nvme0n1p3     239616  492195839 491956224 234.6G Microsoft basic data
/dev/nvme0n1p4 1952446464 1953521663   1075200   525M Windows recovery environme
/dev/nvme0n1p5  492195840  982839295 490643456   234G Microsoft basic data
/dev/nvme0n1p6  982839296  982841343      2048     1M BIOS boot
/dev/nvme0n1p7  982841344  984938495   2097152     1G Linux filesystem
/dev/nvme0n1p8  984938496 1952446463 967507968 461.3G Linux filesystem

I tried to reinstall Windows to /dev/nvme0n1p3 again but this did not help to get it started.
Only Fedora boots.

Comment 3 Hedayat Vatankhah 2022-03-17 11:00:15 UTC
1. Have you properly 'shut down' windows before installing Fedora? Are you able to mount windows partitions in your Fedora right now?

2. If yes, please run this command in a command prompt:
journalctl -f > os-prober.log

Then, open another command prompt and run:
sudo os-prober

When finished, press Ctrl+C where you run journalctl and the attach os-prober.log to this bug (it'd be helpful to investigate the log before uploading to see if you'd want to remove some info from it, although it rarely happens).

Comment 4 Andreas Huppert 2022-03-17 11:59:52 UTC
Created attachment 1866397 [details]
os-prober logfile

Comment 5 Andreas Huppert 2022-03-17 12:16:01 UTC
Prior to installing Fedora Windows was ok and shut down properly. It worked even after shrinking the WIN disk-area by gparted.
Following WIN partitions are mountable: p1, p3, p4, p5

Comment 6 Andreas Huppert 2022-03-17 12:43:24 UTC
(parted) print                                                            
Model: Samsung SSD 970 EVO Plus 1TB (nvme)
Disk /dev/nvme0n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: pmbr_boot

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  106MB   105MB   fat32        EFI system partition          boot, esp
 2      106MB   123MB   16.8MB               Microsoft reserved partition  msftres
 3      123MB   252GB   252GB   ntfs         Basic data partition          msftdata
 5      252GB   503GB   251GB   ntfs                                       msftdata
 6      503GB   503GB   1049kB                                             bios_grub
 7      503GB   504GB   1074MB  ext4
 8      504GB   1000GB  495GB   btrfs
 4      1000GB  1000GB  551MB   ntfs                                       hidden, diag

os-prober:
Mar 17 12:53:35 fedora root[4027]: os-prober: debug: running /usr/libexec/os-probes/50mounted-tests on /dev/nvme0n1p3
Mar 17 12:53:35 fedora root[4027]: 50mounted-tests: debug: mounted using GRUB ntfs filesystem driver
Mar 17 12:53:35 fedora root[4027]: 50mounted-tests: debug: running subtest /usr/libexec/os-probes/mounted/05efi
Mar 17 12:53:35 fedora root[4027]: 05efi: debug: Not on UEFI platform
Mar 17 12:53:35 fedora root[4027]: 50mounted-tests: debug: running subtest /usr/libexec/os-probes/mounted/10freedos
Mar 17 12:53:35 fedora root[4027]: 10freedos: debug: /dev/nvme0n1p3 is not a FAT partition: exiting

The reason of not detecting p3 as WIN-partition could be the fact: "Not on UEFI platform". Why ever, os-prober is expecting p3 to be FAT.

Comment 7 Hedayat Vatankhah 2022-03-17 22:20:03 UTC
Which version of Windows are you using? Are you using Windows 11?

Comment 8 Andreas Huppert 2022-03-18 08:49:20 UTC
I have installed WIN10. I cannot upgrade to WIN11 because of my old graphic card,
This is the reason why the BIOS prevents running in UEFI mode and falls back to CSM.

Additional info: There is a pretty new  ACER-Aspire notebook where initially a WIN10
was installed. The BIOS runs in UEFI mode. By using the same strategy (i.e. installing
Fedora after gparted) I was successful: There is a "Windows Boot Manager" entry in the 
GRUB-menu and Windows can be loaded.

Comment 9 Hedayat Vatankhah 2022-03-21 22:44:03 UTC
That's weird, seems that it should work fine. Anyway, please either add 'set -x' to the start of '/usr/bin/os-prober' (You can change 'set -e' at the beginning of this script to 'set -e -x') and then run os-prober again and send the new logs as before; or mount your p3 partition somewhere (e.g. /mnt) and the get the output of the following commands:

ls /mnt/boot /mnt/boot/bcd

Comment 10 Andreas Huppert 2022-03-22 08:52:48 UTC
Created attachment 1867403 [details]
os-prober logfile with set -e -x

Comment 11 Andreas Huppert 2022-03-22 09:09:09 UTC
Created attachment 1867410 [details]
tree command output on partition p1

This should be the real EFI boot-partition. (In the referred ACER-Aspire Fedora added some files to it and generated an entry in the GRUB-menu: "Windows Boot Manager on /dev/nvme0n1p1")

Comment 12 Andreas Huppert 2022-03-22 09:30:05 UTC
Created attachment 1867411 [details]
tree command output on the referred ACER-Aspire

This is the result of the Fedora-installation in a UEFI-capable system.
In my not-UEFI computer it generated the partition p6 of type BIOS boot.

Comment 13 Andreas Huppert 2022-03-22 09:57:11 UTC
Contents of partition p3:
[root@fedora Downloads]# ls -l /mnt
total 524324
drwxrwxrwx. 1 root root         0 Dec  7  2019 '$Recycle.Bin'
drwxrwxrwx. 1 root root         0 Dec  7  2019  PerfLogs
drwxrwxrwx. 1 root root      4096 Oct  6 15:30  ProgramData
drwxrwxrwx. 1 root root      4096 Dec  7  2019 'Program Files'
drwxrwxrwx. 1 root root      4096 Oct  6 15:30 'Program Files (x86)'
drwxrwxrwx. 1 root root         0 Mar 15 18:26  Recovery
-rwxrwxrwx. 1 root root         0 Mar 16 12:06  Recovery.txt
drwxrwxrwx. 1 root root      4096 Mar 16 10:44 'System Volume Information'
drwxrwxrwx. 1 root root      4096 Dec  7  2019  Users
drwxrwxrwx. 1 root root     16384 Mar 16 12:20  Windows
-rwxrwxrwx. 1 root root 536870912 Mar 16 12:17  WinPEpge.sys

It seems to me that the Fedora istallation did not expand the partition p1 in case of a non-UEFI system but generated the p6 instead:
/dev/nvme0n1p6  982839296  982841343      2048     1M BIOS boot
This partition is not present (visible) in the referred UEFI system.

Comment 14 Hedayat Vatankhah 2022-03-22 20:32:45 UTC
Hey! Have you installed Windows in UEFI mode and then switched to CSM mode and installed Fedora?! Seems like your Windows is installed in UEFI mode. If that's the case, Fedora behavior is correct. You cannot boot Windows when system is booted in CSM mode. Till now, I thought you installed both OSes in CSM mode. If Windows is installed in UEFI mode, you should also install Fedora in UEFI mode too. Also, I don't understand why CSM/UEFI is related to your graphics card?!

Comment 15 Andreas Huppert 2022-03-23 07:13:22 UTC
No!!! My BIOS falls back automatically to CSM on the next reboot even if I want to turn it to UEFI. The reason is my old graphic card. (BIOS told so.) I installed both WIN10 and after gparted Fedora-35 in CSM mode.

Comment 16 Andreas Huppert 2022-03-23 08:18:23 UTC
Unfortunately old graphics cards (GPU-s) are not UEFI compatible! (You can see this on the WEB.)

Comment 17 Hedayat Vatankhah 2022-03-23 20:55:34 UTC
OK, therefore please find which partition includes Windows' Boot directory. It is clearly not in p3 (no dir named boot). There is a boot directory in p1, but this is an EFI partition and probably not used in CSM boot. 
Then..... is there any 'boot' directory in p4 or p5?
If not, then I don't know how your Windows booted, and neither does os-prober.

Comment 18 Andreas Huppert 2022-03-24 07:50:08 UTC
Next week I'm going to remove everything from the nvme0n1 SSD drive and then to reinstall WIN10. 
Then - after gparted - I make a detailed list of the contents of all partitions using the Fedora-35 live-CD.
Then I will install Fedora-35 again and check the contents of all partitions and give you a feedback.
Are you agree or you will suggest a different way???

Comment 19 Hedayat Vatankhah 2022-03-24 08:29:15 UTC
There is no need to create a full list. We are only interested in top level directories. In a CSM install, we expect to find a 'boot' directory in one of the windows partitions at the top level. 

And I have a question: who have created the entries in the EFI partition (p1)? There is even a Microsoft directory, so at least once a Windows have been installed in this disk in EFI mode.

Comment 20 Andreas Huppert 2022-03-24 09:13:14 UTC
The story is as follows: I installed first WIN10 and then Fedora - all this in CSM mode. Then Windows was no more to boot. So I tried to install WIN10 a couple of times. Maybe this changed something but Windows remained hidden for the os_prober. The tree command outputs have been recorded after all this. I want to repeat the installation process to see the uncorrupted state.

Comment 21 Hedayat Vatankhah 2022-03-24 10:06:32 UTC
OK, that's fine. So, please send a summary of all your partitions and their root contents after installing windows (before trying to install Fedora).

Comment 22 Andreas Huppert 2022-03-28 13:19:17 UTC
Created attachment 1868709 [details]
tree command output on partition p1

Comment 23 Andreas Huppert 2022-03-28 13:31:18 UTC
I installed WIN10 again an then booted the Fedora-35 live-CD:

os-prober output: !!!!
/dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi

fdisk -l output:
Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 970 EVO Plus 1TB            
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: 478E8FE5-664E-416F-942F-13893A547F36

Device              Start        End    Sectors   Size Type
/dev/nvme0n1p1       2048     206847     204800   100M EFI System
/dev/nvme0n1p2     206848     239615      32768    16M Microsoft reserved
/dev/nvme0n1p3     239616 1952445812 1952206197 930.9G Microsoft basic data
/dev/nvme0n1p4 1952446464 1953521663    1075200   525M Windows recovery environment

parted output:

(parted) print                                                            
Model: Samsung SSD 970 EVO Plus 1TB (nvme)
Disk /dev/nvme0n1: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  106MB   105MB   fat32        EFI system partition          boot, esp
 2      106MB   123MB   16.8MB               Microsoft reserved partition  msftres
 3      123MB   1000GB  1000GB  ntfs         Basic data partition          msftdata
 4      1000GB  1000GB  551MB   ntfs                                       hidden, diag

For contents of p1 see new attachment!

Contents of p3:
[root@localhost-live tmp]# cat p3.list
total 5293952
drwxrwxrwx. 1 root root          0 Mar 28 08:36 $Recycle.Bin
drwxrwxrwx. 1 root root          0 Mar 28 08:28 $WinREAgent
lrwxrwxrwx. 2 root root         10 Mar 28 05:49 Dokumente und Einstellungen -> /mnt/Users
-rwxrwxrwx. 2 root root       8192 Mar 28 08:36 DumpStack.log.tmp
-rwxrwxrwx. 1 root root 3390914560 Mar 28 08:36 hiberfil.sys
-rwxrwxrwx. 1 root root 2013265920 Mar 28 08:36 pagefile.sys
drwxrwxrwx. 1 root root          0 Dec  7  2019 PerfLogs
drwxrwxrwx. 1 root root       4096 Mar 28 08:00 ProgramData
drwxrwxrwx. 1 root root       8192 Mar 28 08:01 Program Files
drwxrwxrwx. 1 root root       4096 Mar 28 08:00 Program Files (x86)
lrwxrwxrwx. 2 root root         18 Mar 28 05:49 Programme -> /mnt/Program Files
drwxrwxrwx. 1 root root          0 Mar 28 05:49 Recovery
-rwxrwxrwx. 1 root root   16777216 Mar 28 08:36 swapfile.sys
drwxrwxrwx. 1 root root       4096 Mar 28 08:00 System Volume Information
drwxrwxrwx. 1 root root       4096 Mar 28 07:59 Users
drwxrwxrwx. 1 root root      16384 Mar 28 08:36 Windows

Contents of p4:total 0
drwxrwxrwx. 1 root root 0 Mar 28 05:49 Recovery
drwxrwxrwx. 1 root root 0 Mar 28 05:49 System Volume Information

Comment 24 Andreas Huppert 2022-03-29 07:20:55 UTC
After shrinking p3 by using gparted (to make place for Fedora):
Windows is still working and os-prober detects the Windows system, like before.
As we know, if I now installed Fedora-35 from the live-CD to the free area on the harddisk WIN10 could not be booted any more and os-prober would not detect it either.

Comment 25 Hedayat Vatankhah 2022-03-29 20:09:21 UTC
To me, it clearly seems that your Windows is booting in UEFI mode. And what I can guess, is that this time you've installed Fedora in UEFI mode too. Your p1 is a valid UEFI partition, and it won't boot anything in CSM mod AFAIK.

I don't recognize any bugs right now.

Comment 26 Andreas Huppert 2022-03-30 07:43:50 UTC
Maybe, this could be a bug in the WIN10 installation: It should recognize the CSM mode of BIOS. Though there is no explanation for the fact that the os-prober of FEDORA-35-live still detects the installed WIN10 and it doesn't after installing FEDORA to the hard-drive. In my opinion the Fedora installation should see the EFI partition and extend it by own boot-data like in UEFI mode. (I know it is not correct but a useful work-around. We cannot fix a Windows-bug.) The current strategy of the Fedora installation is definitely wrong: It cannot be that Windows simply disappears (i.e. inaccessible) after installing Fedora!!! If needed I can provide a screenshot showing that BIOS falls back to CSM because of the old GPU (graphic card) even if I set UEFI mode. If nothing will be changed in the Fedora installation I have two options: Either I buy a new-fashioned graphic card or I install Fedora to an external USB-disk. None of them is satisfactory.

Comment 27 Hedayat Vatankhah 2022-03-30 07:56:03 UTC
From what I can see, Fedora Live ISO is also booted in UEFI mode. Are you sure that if you install Fedora, it won't detect windows? I doubt, because Fedora runs os-prober in the installer, so if you run os-prober in Live booted Fedora, then the installer would find it too. I'd suggest you to boot Fedora live, and if it detects Windows while running in Live mode, install Fedora. It must put an entry for Windows in grub menu. Please try it and let me know the results. 

But, if after installation, grub is booted in CSM mode, then the problem would not be if there is an entry for Windows in grub or not; the problem is how can we actually boot Windows!

But, from all you've provided till now, not only your Windows is installed and booted in UEFI mode; but also Fedora Live is also booted in UEFI mode, otherwise it'd not detect EFI windows as below:

/dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi


I don't care if the system tells you it is running in CSM mode or not; this is not important as while as both Windows and Fedora Live think that they are in EFI mode and are booting correctly. To me, your system is booting fine in UEFI mode. So, if your Fedora live detects windows as above, please go and install Fedora. I don't see any reason for you to not see a Windows entry in grub; it all happens in Fedora Live not after installation.

Comment 28 Andreas Huppert 2022-03-30 09:27:55 UTC
I don't know why but now everything is ok - THANK YOU!!!!! If you need it I could send a tree of p1 and grub.cfg. Both of them are ok.

Comment 29 Hedayat Vatankhah 2022-03-30 14:13:25 UTC
I also don't know, but "it seems" that somehow the previous time you've booted your Fedora Live disk in CSM mode, but now everything runs in UEFI mode (or at least, they think they do! doesn't matter anyway). 

I'm happy that your problem is fixed. :) No, there is no need to send anything.

Comment 30 Andreas Huppert 2022-03-30 22:01:29 UTC
Almost forgotten: After the first installation (i.e. Windows --> Linux) which went wrong as reported, I updated the BIOS!!! This fact might be an explanation for the success at the second trial.

Comment 31 Hedayat Vatankhah 2022-03-30 22:57:51 UTC
Yeah, that's very likely. I've seen buggy UEFI implementations causing trouble which fixes after UEFI upgrades. 

And I'd say that your OSes are booting in UEFI mode right now.