Creating Customized Windows 8.1 Media (ISO, WIM, Flash Drive) | Part 2

In Part 1 we used Hyper-V to build, update, and sysprep our custom Windows 8.1 Installation. Now we need to make some Install media!

If you’re unfamiliar with this process, or you haven’t built customized Windows media since the XP days, you may not be familiar with WIM files. Essentially, the WIM file is a compressed image which is deployed during Windows installation. (Think of it like extracting a large .ZIP file.) If you take a look at your Windows 8.1 install media, you’ll find that amongst the plethora of files, the largest will be \Sources\install.wim – approximately 3.1 GB on x64 media.

The last step you completed in Part 1 was creating a second Checkpoint (named Complete). I’ll explain why, next.

Creating a WIM file

As mentioned above, the install.wim file is the actual source used when installing Windows 8.1. Thus, we need to create our own WIM file, and replace the stock one with it. To do this, we need to “capture” the last Checkpoint.

On your host (physical machine), open up Disk Management.
WIN+X > Disk Management
DiskMgmt

  • Navigate to Action > Attach VHD
    AttachVHD
  • Click Browse
    AttachVHDBrowse
  • Navigate to the directory where the virtual disks are stored for stage01.
    By default this directory is: C:\Users\Public\Documents\Hyper-V\Virtual hard disks/
  • In the bottom right, change Virtual Disk files (* .vhd, * .vhdx) to All files (* . *)
    AllFilesVHD
  • Select the file with the most recent Date Modified – this is your Complete Checkpoint!
    FindStageVHD
  • Click Open
  • Check box Read Only and then click OK.ReadOnlyAttach

At this point you will see one new disk with two partitions. Make note of the second partition drive letter (in my case, the F: Drive).
DiskMgmt

  • Open the Command Prompt with Administrator Rights.
    • WIN+X > Command Prompt (Admin)
      CommandPromptAdmin
  • Type dism /capture-image /imagefile:c:\customInstall.wim /capturedir:F:\ /name:"Windows 8.1 Enterprise - Customized by: Joe Wright" /Description:"Windows 8.1 Enterprise - Customized by: Joe Wright" /compress:maximum /checkintegrity /verify /bootable – replacing F: with the second partition drive letter you made note of earlier – and replacing “Customized by: Joe Wright” with whatever you want.

Depending on your processing power, this may take a little while. When complete, you will see “This operation completed successfully.” You should now see a file named “customInstall.wim” at the root of your C:\ Drive.
DISMRun

Once confirmed, head back into Disk Management and right-click the Read-Only VHD disk and click Detach VHD. Click OK when prompted to confirm.
DetachVHD

Build the Customized Media

  • Double click the stock ISO you used to install Windows in stage01 to mount it within File Explorer.
  • Open This PC and double click the newly mounted drive.
    (In my case, Drive E: IR3_CENA_X64FREV_EN-US_DV9)
  • CTRL+A (to select all) and CTRL+C (to copy)
  • Create a new folder named WinExtract off your C:\ drive
    • (Another location is fine too, but these instructions will be assuming C:\)
  • Navigate to C:\WinExtract\ and CTRL+V (to paste).
    CopyToWinExtract
  • After the copy completes, navigate to C:\WinExtract\sources\ and delete the install.wim file.
    DeleteWIM
  • Move C:\customInstall.wim (your custom WIM) to C:\WinExtract\sources\.
  • Rename C:\WinExtract\sources\customInstall.wim to install.wim.
    MoveWIM

At this point, you are ready to create your ISO.

Create UEFI Bootable ISO

  • Open Command Prompt (Admin)
  • Change Directory to: C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\
  • Run oscdimg -m -o -u2 -lIR3_CENA_X64FREV_EN-US_DV9 -udfver102 -bootdata:2#p0,e,bC:\WinExtract\boot\etfsboot.com#pEF,e,bC:\WinExtract\efi\microsoft\boot\efisys.bin C:\WinExtract\ C:\en_windows_8.1_enterprise_with_update_x64_dvd_CUSTOM.iso
    OSCDIMG

Once complete, you now have a UEFI bootable ISO named en_windows_8.1_enterprise_with_update_x64_dvd_CUSTOM.iso located at the root of your C:\ Drive!

You can test to make sure it works by creating another Virtual Machine within Hyper-V and choosing Generation 2 (UEFI bootable).
Gen2

Make UEFI Bootable USB Disk

If you’ve ever needed to create a UEFI bootable USB disk before, you may be familiar with the (brilliant) product named Rufus. It’s a very straightforward Windows ISO to USB tool which, right off the bat, asks if you want to do a GPT partition (UEFI bootable) or a MBR partition (BIOS bootable) drive.

There is only one problem with Rufus – we can’t use it when our new ISO contains a WIM file that is larger than 4 GB!

UEFI / GPT bootable drives require one of two configurations:

  1. The entire drive be formatted as one large FAT32 partition.This is how most flash drives are formatted.
  2. The drive have a FAT32 formatted partition (with EFI boot files) and another (possibly NTFS formatted) partition.
    This is how a UEFI Windows Installation is typically formatted.

Unless you have one of the new (pretty expensive) flash drives that report to your machine as an external hard drive (Fixed Disk), (or you’re using an external hard drive for that matter) neither of these solutions will work for us. This is because FAT32 partitions cannot contain a single file larger than 4 GB and “normal” flash drives cannot have more than one partition.

So how do we install our Custom Windows 8.1 Media via a flash drive?
Use two flash drives – with the help of the Microsoft Deployment Toolkit.

  • Double-Click C:\en_windows_8.1_enterprise_with_update_x64_dvd_CUSTOM.iso to mount your custom ISO. Make note of the drive letter assigned.
    • In my case, the drive letter is E:\
  • Open Deployment Workbench
  • Navigate to Deployment Shares and click New Deployment Share.
    DeploymentShares
  • Accept the defaults (Click Next 5x) and then click Finish.
    NewDeployShare2
  • Navigate to the Operating Systems section and click Import Operating System.
    ImportOS

    • Select Full set of source files and click Next.
      FullSource
    • For the Source directory, click Browse and navigate to the drive letter you made note of earlier.
      (E:\ in my case.)
      SourceDir
    • Click OK, then click Next.
    • Pick a name (or keep the default) and click Next twice to execute the action.
      PickName
  • Navigate to the Task Sequences section and click New Task Sequence
    NewTaskSeq

    • For the Task Sequence ID enter: 1
    • For the Task Sequence Name enter: Install OS
      TaskSeqNameID
    • Click Next
    • Choose Standard Client Task Sequence as the sequence template.
      ClientTaskSeqTemp
    • Select the OS name you imported earlier.
      (Mine is named Windows 8.1 Enterprise).
      TaskSeqOSSelect
    • Click Next 3x
    • Select the Do not specify an Administrator password at this time option and click Next 2x.
      DoNotSpecAdmin
    • Click Finish
  • Navigate to the Advanced Configuration > Media section and click New Media.
    NewMedia

    • Click Browse and navigate to the C:\ drive.
    • Click Make New Folder and name it “Media” > Click OK.
      NewMediaFolder
    • Ensure Selection profile is set to Everything and click Next twice.
      MediaPath
    • Once complete, click Finish.
    • Right-click the new entry named MEDIA001 and click Update Media Content.
      UpdateMediaContent

The previous steps are a quick and dirty walk through of adding your customized ISO into the Deployment Workbench and generating MDT Media. Why we did this will be covered next. If you would prefer, there are many additional customizations that can be accomplished here, however I am not going to cover them in this article.

As established above, the secret to booting our customized media is by utilizing two USB drives. This is why we installed MDT and went through the steps of generating MDT media – MDT allows a “boot” drive (with UEFI support) and a secondary “deploy” drive. Let’s prepare those now.

  • Gather two USB drives and plug them into your host.
    • The BOOT drive can be a 1GB drive.
    • The DEPLOY drive must be large enough to fit your WIM + about 1.2 GB.
      Using our math skills, that would mean a 4 GB WIM + 1.2 GB = 5.2 GB. AKA: we'll need at least a 6 GB flash drive (If such a size exists).
  • Format the BOOT drive as FAT32 and label the volume as BOOT.
  • Format the DEPLOY drive as NTFS and label the volume as DEPLOY.
    FormatFlash

Now we’re ready to start copying data to the drives. Open an Explorer window and navigate to C:\Media\Content\.

  • Perform the following steps for the BOOT drive:
    • Copy the C:\Media\Content\Boot\ folder to the root of the BOOT drive.
    • Copy the C:\Media\Content\EFI\ folder to the root of the BOOT drive.
    • Copy the following files to the root of the BOOT drive:
      • C:\Media\Content\autorun.inf
      • C:\Media\Content\bootmgr
      • C:\Media\Content\bootmgr.efi
        CopyToBoot
    • Create a new folder named Deploy at the root of the BOOT drive.
      NewFolderDeploy
    • Copy the C:\Media\Content\Deploy\Boot\ folder to the Deploy folder on the BOOT drive (the folder you just created).
      CopyDeployFolder
  • Perform the following steps for the DEPLOY drive:
    • Copy the C:\Media\Content\Deploy\ folder to the root of the DEPLOY drive.
      CopyDeployToDeploy

Safely remove both USB drives and you are ready for deployment!

Deploy Windows via Flash Drive

  • To deploy, plug both drives into your target machine and UEFI boot to the BOOT drive.
    UEFIBoot
  • Click Run the Deployment Wizard to install a new Operating System.
    RunDeployWiz
  • Select Install Windows 8.1 Enterprise (or whatever you named your WIM) and click Next.
    TaskSeqInstall
  • Follow the prompts to name the computer, join to domain (if desired), move user data (if desired), set Administrator Password, etc.
  • Click Begin to initiate deployment.
    ReadyToBegin
  • Wait patiently as your customized Windows 8.1 Media is deployed to your machine, utilizing UEFI.

Congratulations! At this point, you’ve successfully accomplished a task that drives many admins crazy! Now get up, walk around, and maybe even get some fresh air. You deserve it.

Additional Thoughts: I realize that splitting WIM files would have sped up this process considerably. Additionally, it would have completely negated the need to use a second flash drive or even install MDT at all. Unfortunately, for some reason, Microsoft decided to remove split WIM functionality from Windows 8.1 – thus, I had to find another solution. The benefit to this is that I gained some MDT experience, and going forward I’m going to try and use it for standalone scenarios where SCCM is not available.

Let me know your experience with following these steps! Hopefully they were relatively easy to follow and you didn’t run into too many snags.

Until next time..

  • Ramin

    Thanks a lot! You really surprised me! You are very elite! for some days I have thinking how install win 8.1 x64 by USB in my UEFI Laptop untill I found your precious posts. I will try it and report.

  • BMWS1000RR

    Very useful information. I have a question looking at the level of knowledge you have with respect to MEDIA based deployment I am sure you can help me on this as I never tried Media based deployment before.

    current practice for deploying Windows 7 but the person has left the company without giving me a proper Knowledge transition this is what is been followed ,

    WinPE to enter into DISKPART then ….
    CLEAN
    CREATE PARTITION
    ACTIVE
    ASSIGN C
    EXIT

    I then use Xcopy to copy the CONTENT folder from network share to local disk on the machine C drive…REBOOT this will kick start Task Sequence ……

    But my question is which WinPE do i use? the one in the Deployment ShareBOOT folder or \MediaContentDeployBOOT(Offline Media Folder)

    • echorelay

      To better help you, I’m curious as to why you’re manually running the diskpart command instead of just having MDT create the partitions for you? You’re taking a very long route to achieve what can be accomplished by just installing via the flash drives (or two flash drives in my steps).

      • BMWS1000RR

        Q: why manually running the diskpart command instead of just having MDT create the partitions for you?

        A: That’s the only possible ways to wipe the old OS.

        Q: You’re taking a very long route to achieve what can be accomplished by just installing via the flash drives (or two flash drives in my steps).

        A: Due to security reasons I cannot have the Image on USB …. every time it has to be copied from the network share.

        Hey by the ways after reading your post I am able to get my image working but BITLOCKER is not working any thoughts….Imaging completes without BITLOCKER….any thoughts ?

        this is the ERROR I get with Media based deployment but works when booted via LTI
        FAILURE ( 6739 ): False: Check to see if TPM is enabled

        • echorelay

          I do hate to ask the obvious, but did you enable TPM? 🙂 My apologies for the long delay in my response.

  • Andy Alvarez

    Dude, thank you so much for typing this up! It saved me a ton of studying/learning and stress!

    • echorelay

      Thank you for the kind words, Andy! Glad to hear this helped you out.

  • Daniel

    Nice tutorial with some value, but using MDT and ending up in running around with two flash sticks is nonsense. MDT is for large scale deployment, Windows ICD would be more appropriate.

    • echorelay

      Thanks for your feedback! Unfortunately, Windows ICD did not exist at the time of this blog post. I worked with what was available. Since Microsoft brought back split WIM support in Windows 10, I use that now.

  • JoVaRi

    When I try to use the image created with ‘Oscdimg’, right after booting and pressing “install now” the setup tells me, that the product-key is not valid for the available windows images and that I have to enter a different one.
    When preparing the image, I never entered any product key. Do you have an idea?
    (basically it’s this problem, but I can’t fix it because activation of the image will be done via KMS) –
    https://support.microsoft.com/en-us/help/2796988/windows-8-or-windows-server-2012-installation-may-fail-with-error-message-the-product-key-entered-does-not-match-any-of-the-windows-images-available-for-installation.-enter-a-different-product-key)

    • echorelay

      It sounds like you created a WIM for one edition but used install media from another edition. Are you using Enterprise? If not, you need to delete the EI.CFG file from within the Sources folder on the install media (before you create the ISO). Give that a shot 🙂

      If you’re using Enterprise, you need the EI.CFG file with the contents:
      [EditionID]
      Enterprise

      [Channel]
      Volume

      [VL]
      1

      • JoVaRi

        It is enterprise.
        I used the same image for source file extraction as for the installation in the VM
        EI.cfg has this exact content.

        • echorelay

          hmm interesting. This is Windows 10 or 8.1? What’s the name of the ISO you used to install Windows on the staging VM?

          • JoVaRi

            Windows 8.1 Enterprise 64bit. The ISO was renamed. I’ll do a minimal installation with it and report back.

          • JoVaRi

            Did minimal installation. It worked. Repeated the whole second part and avoided two mistakes: mounting the drive not “Read-Only” and actually running oscdimg as admin.
            Now the problem doesn’t occour anymore … Whatever cause it had … it might be of interest for someone else.

          • echorelay

            That is great to hear! Best of luck going forward and be sure to check back when I create a new walk through with the next version release of Windows 10.