Skip to content

Instantly share code, notes, and snippets.

@moinologics
Last active February 4, 2021 06:46
Show Gist options
  • Save moinologics/ae4ef54d654814b8373678d4678561e2 to your computer and use it in GitHub Desktop.
Save moinologics/ae4ef54d654814b8373678d4678561e2 to your computer and use it in GitHub Desktop.
install Windows 10 on vhd & dual boot a pc
in this gist, we will see how can we install whole windows 10/8/8.1/7/xp/vista on a singal vhdx(virtual hdd) file.
Step 1: Create a VHDX from diskpart
a) From the Command Prompt, open Diskpart.
PS > diskpart
b) Create and prepare a new VHDX. In this example, we create a 25 GB fixed-type VHDX.
DISKPART > create vdisk file=C:\windows.vhdx maximum=25600 type=fixed
c) Attach the VHDX. This adds the VHDX as a disk to the storage controller on the host.
DISKPART > attach vdisk
d) Create a partition for the Windows files, format it, and assign it a drive letter. This drive letter will appear in File Explorer.
DISKPART > create partition primary
DISKPART > format quick label=vhdx
DISKPART > assign letter=v
e) Exit Diskpart
DISKPART > exit
Step 2: Apply a Windows image to the VHD
a) mount the iso file of the windows 10/8/8.1/7/xp/vista.
Note - you can mount iso on windows 10 by just doubal click, on the pc other than wondows 10, you can use power iso like software.
b) identify the drive letter of the mounted iso, and search for install.wim file.
Note - for windows 7, it is in F:\sources\install.wim, where F is drive letter of mounted iso.
c) Now open power shell or command prompt as admin & Run the command
PS > Dism /Apply-Image /ImageFile:install.wim /index:1 /ApplyDir:V:\
this will take some time & will install the windows on vhdx file.
Step 4: Add a boot entry (for dual boot the pc)
1. From your destination PC, open Diskpart (if necessary) and identify the drive letters of the VHDX and the system partition, for example, V.
PS > diskpart
DISKPART > list volume
DISKPART > exit
2. Add a boot entry to the device. You can add multiple VHDX files using this method.
PS > cd v:\windows\system32
for BIOS boot -
PS > bcdboot v:\windows /s S: /f BIOS
or for UEFI boot -
PS > bcdboot v:\windows /s S: /f UEFI
3. Remove the Windows PE USB key.
4. Restart the destination PC.
source - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/boot-to-vhd--native-boot--add-a-virtual-hard-disk-to-the-boot-menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment