Attach a .vhd in Windows Server 2008 R2.
Windows Server 2008 R2 (and Windows 7) has the ability to create and attach VHDs directly from Disk Management. Unfortunately they detach if your server reboots. This can be fixed with a little scripting.
Open the Group Policy Object Editor mmc Snap-in and drill down to Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts -> Startup.
Create two new scripts. The first script is a diskpart script to actually mount your VHD file. Call it step1.txt.
select vdisk file=”c:\mydisk.vhd”
The second script is a .cmd script that just runs diskpart with the /s switch and passes in your diskpart script file. Call it AttachVHD.cmd
diskpart /s step1.txt
Set the AttachVHD.cmd as a Startup script in the Group Policy Object snap-in.
Windows will now automatically attach your .vhd when your system reboots.