How do I install Windows on a virtual hard disk (VHD) from within a running Windows system?

1

1

If you just try to attach a VHD and then install Windows to a partition inside it, it will tell you that it's a "surfaced virtual disk" and that Windows cannot be installed to that partition.

But obviously it's a lie, because this is possible when booting directly off a DVD. :-)

So how do you do that from a running system?

user541686

Posted 2012-06-11T02:57:07.273

Reputation: 21 330

Answers

4

First of all, a warning: Close all your programs and save all your files before attempting this! Make sure there is nothing important still in the system cache! (Sync is handy for this.)

Windows does NOT perform a "graceful" shutdown using this trick!

When you're done with that, to 'trick' the installer thinking it's in Windows PE, simply create the registry entry

HKEY_LOCAL_MACHINE\System\CurrentControlSet\MiniNT

and run the installer from the DVD. It will now allow you to install to a VHD.

Once the installer says "Restarting in 10 seconds...", press Alt-Tab to go back to the registry editor (have it open!) and delete the MiniNT key so that you don't trick any other programs into thinking your current system is a PE system. :)

Now the system will reboot the kernel (the user mode shutdown process is bypassed) and should continue installing Windows to your partition.

Note 1: Drive letters probably won't be preserved this way, though.

Note 2: You can "try" to attempt to "fix" the drive letters immediately on the first reboot, before the second, when the installation is about to perform system-specific configurations. If you do so, however, be warned: Your \Users\All Users junction (and all the tens of other junctions/symbolic links) will point to your old system drive, not the new one! So you have to be prepared to fix this manually -- and yes, it's a pain to do this 'correctly' without corruption.

user541686

Posted 2012-06-11T02:57:07.273

Reputation: 21 330

Some of the negative side effects of MiniNT are described here.

– Vlastimil Ovčáčík – 2017-10-26T11:50:19.543

Installation media created using recent MediaCreationTool.exe no longer let me skip the warning about installing Windows on VHDX. Running setup using this trick issues same warning, but it can be skipped! This is now my favorite way to install Windows on VHDX.

– Vlastimil Ovčáčík – 2017-10-26T13:08:43.860

You could, in theory also edit the registry offline i suppose, or create a script that adds and removes the registry entry . Really cool trick tho – Journeyman Geek – 2012-06-11T03:17:15.073

0

Performing an install of Windows to a partition inside of a VHD, while running Windows consists of a few steps and some specific tools.

Tools required:

  1. ImageX - specifically for the platform of your current installation of Windows (i.e. x64 or x86). You can get it as part of the Windows Automated Installation Kit here: http://www.microsoft.com/en-us/download/details.aspx?id=5753.
  2. DiskPart - built into Windows 7.

High level steps:

  1. Using DiskPart, create the VHD. Then mount it in Windows, partition it, and assign a drive letter to the partition you'll want to use for the new installation. For discussion, let's say you assign the drive letter as "Z:\".
  2. Get access to the Windows 7 "install.wim" file. You can find it in the "\sources" directory of the Windows 7 installation disc. For discussion, let's say you have that mounted/inserted into drive letter "D:\".
  3. Using ImageX from an Administrator command-line, apply the Windows 7 "install.wim" file to the new VHD's partition by using the following command:

    imagex.exe /apply D:\sources\install.wim 1 Z:\

You can find more info about the ImageX tool here: http://technet.microsoft.com/en-us/library/cc749447%28v=ws.10%29.aspx.

I hope that helps. I have used the above technique to make fresh installs of Windows 7 and Windows Server 2008/2008 R2 for both virtual machines and "boot from VHD" scenarios.

dl8on

Posted 2012-06-11T02:57:07.273

Reputation: 1