Deploying Win 7 to Boot From VHD with MDT 2010
One of the more difficult scenarios that customers have found in the past is multi-booting a new OS. The effort needed to re-partition the drive to allow for the new OS is sometimes too great. One new solution that is gaining ground in deployment is Boot From VHD. This allows you to take a VHD file with Windows 7 or Windows Server 2008 R2 and boot your machine to it. This means that you can take advantage of the physical hardware of your machine while not having to repartition your drive for Win 7 and keep your original OS intact. More information on how to Boot From VHD can be found here https://edge.technet.com/Media/Windows-7-Boot-from-VHD/ .
MDT 2010 Beta 1 can deploy Win 7 Beta out-of-the-box however, it deploys it to the Disk 0 Partition 1 by default. In order to change this behaviour so that MDT 2010 deploys Win 7 to a VHD and leaves your existing OS you can follow the steps below:
1. Create a Task Sequence to install Win 7 in MDT 2010
2. Insert the following 3 steps in the Pre-Install \ New Computer only Phase:
a) Disable the format and partition disk step
b) Insert a Set Task Sequence Variable Step to set the path for the VHD with the variable BootVHDLocation. Ensure that path DOES NOT EXIST already on the machine.
c) Insert a Set Task Sequence Variable Step to set the size of the VHD (in MB) with the variable BootVHDSize. Ensure that there is enough space on the drive as the VHD may grow to this size.
d) Insert a Run Command Line step to run the command line cscript.exe "%SCRIPTROOT%\ZTIDiskPartVHD.wsf"
3. Copy the attached script below to your Distribution$\Scripts folder.
4. Run your task sequence on a machine and watch Win 7 install into a VHD. Once the process is done, your machine will have a boot menu similar to this:
Please note, this script does not deal with BitLocker encrypted drives and Boot From VHD will only work with Windows 7 Beta or Windows Server 2008 R2. As always test this out and feel free to post comments.
Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .
This post was contributed by Aly Shivji a consultant with Microsoft Services - U.S. East Region.
Comments
Anonymous
January 01, 2003
Janke, I did see you posted parts of your task sequence and logs, I chose not ot publish them for cleanliness reasons. I tried your scenario with 2 partitions existing on the drive (C & D )and I didn't run into the issue you had. Can you tell me your exact disk scenario. Basically, your physical disks and their disk numbers, paritions, volumes, etc. I would also like to know if you have any other disk-related steps in your task sequence - i.e. BitLocker or other format steps. Third, what OS is your original system drive. Thanks, AlyAnonymous
January 01, 2003
This works really well. I took it a step further and installed an automated way to esentially take snapshots and revert back to previous VHD configurations by using Diff VHDs. Run a script, it modifies the BCD to boot from a specially crafted WinPE boot WIM, it boots runs another script to manipulate the VHDs with Diskpart, modify the BCD again to boot back into Windows and you're done. So I can hand out a loaner, and when I get it back I can have it back clean again in 4 minutes. This technology is pretty slick.Anonymous
January 01, 2003
Janke, I believe that is in fact your issue. Unfortunately, there is no easy way to predict which drive will come up with which letters. Drive C: is usually Disk 0 Partition 1. If you find that your combination is coming up with a different letter for C:, change the value of the variable BootVHDLocation to reference that drive. MDT, in fact, has logic to move any other drive/partition combo that grabs C: to another letter. Please post a comment if this works for you and I will add a note to this post. Thank you for your diligence on this. AlyAnonymous
January 01, 2003
Janke, When you copy the script into the Distribution$Scripts folder it will be in %SCRIPTROOT% and therefore accessible even before the Copy Scripts task. As for the task stopping, I need a little more detail as to your issue. I do know that if you choose a large VHD size it will take some time depending on the space required to format the VHD drive. You might want to leave it for a little while and see if it continues otherwise feel free to post with some more detail of your task sequence. Cheers, AlyAnonymous
January 01, 2003
The comment has been removedAnonymous
March 04, 2009
Did you mean to say MDT 2010 Beta 1?Anonymous
March 05, 2009
I can't get this working. When I PXE boots and chooses this task it just stops. Should this script be on the PE image ? This does happen before copy scripts, and then the command ztidiskpartvhd does not exist.Anonymous
March 09, 2009
The C: drive is not really the c-drive but the windows 7 boot drive. I am sorry i did not include that in the previous post. So when I boot on PE, the PE sees the small boot partition as the C-drive and not det OS partition. Could that be the issue, that there isnt enough space on C: Win 7 will always make the boot partition as far as I know (200MB)Anonymous
May 26, 2009
Hi Aly, This is not working for us - the task sequence 'hangs' at [Log Diskpart Commands]. If we Remove the directories MININT and _smstasksequence, reboot and restart Litetouch, it works. In effort to resolve, we remarked out [Log Diskpart commands] and found the task sequence fails with a Format failure. We have concluded that the Virtual disk is created, but does not attach therefore fails. Any advice appreciated. Regards, MarcAnonymous
August 10, 2009
Ill try not to make this to long. I have built and captured a desktop and laptop image and then merged the 2 wim files together to make a single wim with 2 indexes. I now want to deploy it so it deploys natively on a clean HDD to a parent VHD (read only), and any changes automatically get created on a differencing disk. I then want to have the ability to restore the differencing disk to a previous point in time. IE backup the differencing vhd daily and then restore one of the daily backups to the parent, Hence only the last day or so changes are lost and not the whole lot. We need people in the regions where its hard to get an onsite tech there, to be able to say boot into maybe a PE environment in the boot choices and when they boot in it runs a script to restore the last or second last differencing vhd. But from all the research I have done it seems I would need to know the GUID, which presents a problem when trying to get this in a script and then use it. So all a user would do is reboot, start the option that says "emergency" ,it runs a script and then reboots for them ready to go. It would be great if i could deploy this whole thing through the 2010 MDT. If you could help in any way, please please let me know. I would be so grateful. Thanks Heaps DazAnonymous
August 13, 2009
I was wondering if anyone had tried setting up an image with a premade VHD installed in it and then having a script set it up as a boot option. I can not find how to have a script set a vhd as a secondary boot option.Anonymous
November 05, 2009
The comment has been removedAnonymous
March 06, 2010
Hi. Im trying to your solution with MDT 2010 and SCCM, but get the following error. The process cannot access the file because it is being used by another process.Anonymous
March 13, 2011
Tomas Lovén is correct, my deployment was hanging on "Preparing Disk Partition" when attempting to deploy on a machine that already had win 7 installed. Updating the wsf so create an expandable vhd fixed the issue.Anonymous
May 13, 2011
Hi So I tried this, and alas.. it did not work... right now it just hangs @ Running action: run diskpartVHD Preparing Disk Partitions... Nothing in the log files... :(Anonymous
July 30, 2014
I get the same error as BlackDragonIce.
Have you found a solution for your system?