How do I install Windows on a virtual hard disk (VHD) from within a running Windows system?
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?
Solution 1:
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.