Introduction
This is the second article in the “Boot Configuration” series. I never expected such a simple topic could turn into a series, because I thought I had already explained the relevant concepts of boot configuration clearly in the first article, and I had successfully configured dual boot many times. However, recently I encountered a huge pitfall while setting up a dual boot with Windows and Linux on separate drives, so I felt it was necessary to write another article to document it.
The other article in this series goes into more detail about the basic concepts of boot configuration and how to configure multi-system boot entries, so I recommend reading it first:
Pitfalls of Dual Booting Windows/Linux on Separate Drives
I originally thought that after the above exploration, I would be very familiar with multi-system boot entries. So when installing a dual boot of Windows and Linux on a dual-drive computer, I was full of confidence, thinking that it would be easier to install the two systems separately since I had already managed to install multiple systems on the same drive. However, reality slapped me in the face, and in the end, I couldn’t even solve it gracefully.
Background
Let me explain my basic situation: my computer has two solid-state drives, A (1TB) and B (500GB), both installed in the M.2 slots on the motherboard. The M.2 slot for drive A is closer to the CPU, while drive B is slightly farther away. Does the distance from the CPU matter? I originally thought it didn’t, but I eventually found out that it seemed to be a huge influencing factor.
I chose to use Fedora 42 as my main operating system, so I installed it on the 1TB solid-state drive A. Windows 11 is just an auxiliary system, installed on the 500GB drive B. According to convention, when installing a dual boot of Windows and Linux, it is recommended to install Windows first, because if Linux is installed afterward, it will overwrite the Linux bootloader, making Linux unbootable. However, when I powered on the machine, I had already installed Fedora 42 on drive A and had been using it for a few days, so I was too lazy to clean it up. Moreover, I thought I had a good grasp of boot configuration, and even if I installed Linux first and then Windows, it would just be a matter of adjusting the boot configuration. Thus, I had my first failed attempt.
First Failed Attempt
The failure process can be summarized as follows:
-
First, I installed Fedora 42 on drive A and successfully booted into the system.
-
Next, I attempted to install Windows 11 on drive B. The safest approach would have been to remove drive A and leave only drive B for the Windows 11 installation. This way, Windows 11 would be completely installed on drive B without affecting Fedora 42 on drive A. However, I was too lazy to open the case, and the M.2 slot for drive A was blocked by the graphics card, making it even more troublesome to remove. So I thought, could I hide drive A during the Windows 11 installation?
-
To hide drive A, my first thought was to use the BIOS settings to disable drive A, but I found that my MSI motherboard didn’t have this feature. My Z890 is considered a mid-to-high-end motherboard, yet it lacks such a basic function. So I had to find other ways to hide it. After some exploration, I discovered that I could use the Diskpart tool during the Windows installation to hide drive A. The specific steps are as follows:
-
Start the Windows installation program, and when you enter the first installation interface (the one where you select the language), press
Shift + F10to open the command prompt. -
In the command prompt, type the following command to start the Diskpart tool:
1diskpart -
Then enter the following command to list all disks:
1list disk -
Find the disk number of drive A (for example,
Disk 0), and then enter the following command to select drive A:1select disk 0 -
Finally, enter the following command to take drive A offline:
1offline diskThis way, during the Windows installation process, the installer will not be able to see drive A.
-
Exit the Diskpart tool:
1exit -
Close the command prompt and continue with the Windows 11 installation.
-
-
After hiding drive A, I continued with the installation program. When the installation program reached the end, it needed to create the boot entry and then restart. At this point, a problem arose. Although the Windows 11 boot program could not see drive A, it seemed to realize that the drive B it was on was not the first boot drive because the M.2 interface for drive A was closer to the CPU. Therefore, it still tried to write boot information to the drive that was higher in the boot order. However, drive A had already been taken offline. As a result, the Windows installation program stubbornly refused to write the boot information to the lower-priority drive B and reported an error saying
1Windows could not prepare the computer to boot into the next phase of installation. To install Windows, restart the installation.
Thus, this attempt ended in failure.
Second Failed Attempt
With the lessons learned from the first attempt, I didn’t bother with the Fedora system on drive A anymore. After all, I had only used it for a few days and hadn’t made many configurations. So I followed the traditional approach: first install Windows, and it didn’t matter if the Fedora boot entry was damaged; I could just reinstall Fedora afterward. This led to the following operations:
-
Install Windows 11 on drive B without taking drive A offline. This went smoothly, and I was able to install and boot into the Windows system normally.
-
The Windows 11 installation damaged the Fedora boot entry, and I was too lazy to fix it, so I just reinstalled Fedora. After the reinstallation, Fedora could boot into the system normally.
-
However, when I tried to regenerate the GRUB configuration in Fedora using the
grub2-mkconfigcommand, I found that it did not automatically detect the Windows 11 boot entry. It was at this point that I realized the Windows 11 boot program had not written the boot information to drive B, but was still trying to write it to drive A. And Fedora had overwritten it during installation! -
Fine, I just reinstalled Fedora because I was too lazy to fix its boot entry, but now I had to fix the Windows boot entry. But since I was familiar with this task, I began the repair:
-
Adjust the partition on drive B in the Fedora system, create a new 300M FAT32 partition in it, and name it
EFI. -
Restart the Windows 11 installation program from the USB drive, and press
Shift + F10to open the command prompt when entering the first installation interface. -
In the command prompt, enter the following command:
1 2diskpart list diskFind the disk number of drive B (for example,
Disk 1), and then enter the following command to select drive B:1 2select disk 1 list partitionFind the partition number of the newly created EFI partition, as well as the partition number and drive letter of the partition where Windows 11 is installed on drive B. You can determine this by the size of the partitions: the one that is 300M is the EFI partition, and the one that is over 400G is the Windows system partition. It turns out that the EFI partition number is 4, the Windows system partition number is 3, and no drive letters have been assigned. So we assign the drive letter S to the EFI partition and the drive letter C to the Windows system partition.
1 2 3 4 5select partition 4 assign letter=S select partition 3 assign letter=C exitThen, use the
bcdbootcommand to copy the boot files to the EFI partition and create a new boot entry:1bcdboot C:\Windows /s S: /f UEFIThis completes the repair of the Windows bootloader.
-
-
After the repair is complete, restart the computer and enter the BIOS settings to set drive B as the first boot option. This allows Windows 11 to boot normally. However, I primarily use Fedora, so I wanted to add the Windows boot entry to Fedora’s GRUB. I then set drive A as the first boot option, so it would default to Fedora, and when I wanted to boot into Windows, I could just select it from the GRUB menu.
-
So I entered the Fedora system and ran
sudo grub2-mkconfig -o /boot/grub2/grub.cfg. However, Fedora did not detect the Windows boot entry we had just repaired. Runningsudo os-proberalso produced no output, indicating that Fedora could not see the Windows boot entry. I was puzzled; this EFI partition was clearly on drive B, and I had mounted it, so why couldn’t it be seen? -
I found that this EFI partition was somewhat different from the EFI partition created by the installer during a normal system installation. Specifically, the EFI partition created by the installer and the system partition are displayed as a single disk in the file manager of other systems, but now this EFI partition is separate from the system partition on the same disk. I don’t know why the partition I manually created is so out of place. Of course, there is a workaround: manually modify the GRUB configuration to forcefully add the Windows boot entry. But that would not be elegant.
So, this attempt also ended in failure.
Final Solution
I realized that Windows is so rogue that it insists on creating the boot partition on the first bootable disk it detects. So, to make it obediently place both the system and boot entries on drive B, I could only move drive B to the first M.2 slot or remove the drive in the first M.2 slot during the Windows installation.
In short, I still had to open the case.
Since the Fedora system itself was fine, I only needed to remove drive A. Then I could install Windows 11 on drive B. After the installation was complete, I could put drive A back into the motherboard.
After booting into the Fedora system, I ran os-prober and grub2-mkconfig again, and this time it could detect the Windows 11 boot entry.
Summary
I really didn’t expect there to be so many pitfalls when installing a dual-boot system with Windows and Linux on two hard drives. The lessons learned here are:
- If you want to install a dual-boot system on two hard drives, it’s best to insert the hard drive you want to install Windows on into the M.2 slot with a higher boot priority.
- If you must insert the hard drive you want to install Linux on into the M.2 slot with a higher boot priority, then either remove the first hard drive during the Windows installation or use another computer to install Windows on drive B before inserting it into the motherboard.