Saturday, December 31, 2022

Dual boot two windows operating systems

I wanted a windows installation where I could write my book and escape from the apps of my everyday windows operating system. You will find plenty of articles about dual boot with Linux, but I couldn't find one on how to dual boot two windows installations. 

In hindsight, after talking to one of my colleagues, there is an easier way to do the same thing using just the windows boot disk and navigating through the UI wizard. This article is still relevant if you want to understand what the wizard does, if you want complete control, or if you want to upgrade the OS in just one of your partitions.

You will need the installation iso. You can download the windows 11 iso directly from Microsoft. If you are looking for windows 10, you need to download the tool and then save the ISO file as shown in the following screenshots.

Once you get the ISO file, mount it by opening it with windows explorer. In the following examples, we assume that the iso was mounted in drive E:.Open PowerShell in Administrator mode and find the index of the image you want to install.

In my case, I wanted to extract Windows 10 Pro, so my index was six (6), as seen in the following screenshot:

As a side note, when I upgraded to windows 11, I followed the same process, and it seems that Windows 11 Pro is also in index 6, but the image is slightly bigger.
Create a temporary folder in c: or wherever you want to extract the windows installation media (in this example, I created c:\tmp): Extract the target image there: Once the process completes you should see the following:

Shrink one of your partitions to make room for the new windows partition:


Create the new partition where you will install your windows, and disable BitLocker for that drive if it is automatically enabled. Let’s assume that you mounted the new partition as drive P:.
Apply the extracted image to that partition using the following command: In the end you should see the following:

Once this is finished, your new operating system is waiting for you to boot it up to finalize the setup process (drivers/user account etc.). 

To boot the new windows installation, you will need to use the bcdboot command and add the new windows installation path (P:\Windows\) to the list of operating systems you can use. To add it, use the following command:
If you want to modify the record, you can list all UEFI firmware using the bcdedit command. Typing this command in an elevated PowerShell or command prompt will list all entries. Our target record is the one point to the P: drive, and the ID is one of the well-known ones {default}:

Let’s rename it to something more memorable: You can also set how long you will wait for the OS to load and which OS to load first through the “Startup and Recovery” options of the System properties: 

After that, you will need to reboot your machine, select your new operating system, and finalize the setup, and that’s it. Once it’s done, you can use the new operating system as you would typically do. I even upgraded from windows 10 to 11 through the standard Windows upgrade process. 

The same process works if you want to install a new windows installation over an existing installation. In my case, I booted in my “Personal windows”, bitlock unlocked the other windows partition, formatted it, and used the dism /Apply-Image command to apply the windows 11 image. After that, I had to boot in my other windows partition as usual to complete the installation (no need to modify the boot loader). 

An alternative is to boot from VHDX, which is slower than using the actual partition.

Finally, if you are reading this article trying to install an isolated windows installation to try out some software or run an executable you don’t fully trust, you can use the windows sandbox.

References:
More info on the extract image process
More info on the apply windows image process.
BCDBoot reference: 

No comments: