The Deployment Guys

Helping to deploy your world automagically...

Deploying Win 7 to Boot From VHD with MDT 2010

Deploying Win 7 to Boot From VHD with MDT 2010

  • Comments 15
  • Likes

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 http://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

disable

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.

BootVHD01

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.

BootVHD02

d) Insert a Run Command Line step to run the command line cscript.exe "%SCRIPTROOT%\ZTIDiskPartVHD.wsf"

BootVHD03

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:

BootMenu

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.

Attachment: ZTIDiskpartVHD.zip
  • Did you mean to say MDT 2010 Beta 1?

  • 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.

  • 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,

    Aly

  • 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,

    Aly

  • 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)

  • 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.

    Aly

  • 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,

    Marc

  • 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

    Daz

  • 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.

  • Hello Aly,

    Thanks for the nice guide! I tried your steps and all works fine on a new computer with no OS installed (clean disk, prepared with diskpart), however when I ran the task sequence on a computer where I already have XP installed I found a problem. The script would hang at the step where the vhd-file seemed to have been created and formatted (specifically the line FORMAT.COM etc.. would fail).

    After going through the logfiles and running the diskpart commands from the script manually, I noticed that the "create vdisk" command was taking a long time to complete (TYPE=FIXED by default?) and the following commands seemed to run without waiting. So to speed up the VDISK creation I then modified the script to use TYPE=EXPANDABLE instead, and everything has worked fine since then.

    So, the modification I did was at line 164, and the result looks like this:

    DiskPartWrite oExec, "Create vdisk file='" & oEnvironment.Item("BootVHDLocation") & "' MAXIMUM=" & oEnvironment.Item("BootVHDSize") & " TYPE=EXPANDABLE"

    Hope this helps anyone with the same problem!

    (PS. Test was done on Windows XP Pro, VHD installation was Windows 7 Enterprise. Tested on virtual and physical machines)

    /ToLo

  • 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.

  • 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.

  • 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... :(

  • 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.

  • Everything went fine tell the last process Configure SteadyState. Got the below error. Operation system deployment did not complete successfully. Litetouch deployment failed, return code = -2147467259 0x80004005 Failed to run the action: Configure SteadyState. Incorrect function. (error: 00000001; Source: Windows) The excution of the group (State Restore) has failed and the execution has been aborted. An action failed. Operation aborted (Error: 80004004, Source: Windows) Failed to run the last action: Configure SteadyState. Execution of task sequence failed. Incorrect function. (Error: 00000001; Source: Windows) Task Sequence Engine failed! Code: enExecutionFailed Task Sequence execution failed with error code 80004005 Error Task Sequence Manager failed to execute task sequence. Code 0x80004005 I tried twice with the same disk and then recreated the ISO and still get the same error

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment