Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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 Jun 11 '12 at 3:17

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.