Creating WIM Images For System Deployment Using Windows 7 PE 3.0
Creating WIM Images For System Deployment Using Windows 7 PE 3.0
Table of Contents
Introduction: ................................................................................................................................................. 4 Creating a basic Windows PE disk for troubleshooting or image capture or deployment: .......................... 6 Installing Drivers ........................................................................................................................................... 9 Installing drivers to offline Windows PE image: ....................................................................................... 9 Installing drivers to running Windows PE: ................................................................................................ 9 Capturing a WIM disk images using Windows PE and ImageX: .................................................................. 10 Capture to USB or local drive: ................................................................................................................. 10 Capture to a network file share: ............................................................................................................. 11 Partition and Format the Hard Drive from Windows PE: ........................................................................... 12 Partition and Format drive from Windows PE Single Partition: ............................................................. 12 Partition and Format drive from Windows PE Two Partitions: .............................................................. 13 DISKPART Scripting:................................................................................................................................. 14 Deploying WIM images: .............................................................................................................................. 15 Deploy from USB drive: ........................................................................................................................... 15 Deploy from Network Share: .................................................................................................................. 15 Deploy from CD/DVD: ............................................................................................................................. 16 Command Files for automation of Base Windows PE ISO Image: .............................................................. 17 Create_Mount.cmd ................................................................................................................................. 17 Install_Packages.cmd .............................................................................................................................. 17 Install_Drivers.CMD ................................................................................................................................ 18 Commit_Changes.cmd ............................................................................................................................ 18 Create_ISO.CMD ..................................................................................................................................... 18 Build_All.CMD ......................................................................................................................................... 18 Further Customizations:.............................................................................................................................. 20 Adding your own startup commands or applications............................................................................. 20 WIM Imaging Tutorial v3.0 Page 2
Remove boot prompt.............................................................................................................................. 20 Using Ghost instead of ImageX ............................................................................................................... 20 Modify the WinPE registry ...................................................................................................................... 21 Add a Language Pack and Change Locale ............................................................................................... 21 Appendices:................................................................................................................................................. 22 Appendix A: Using Windows 7 Driverpacks from Driverpacks.net ........................................................ 22 Appendix B: Exclude files during capture using an ImageX configuration file ....................................... 22 Exclusion List Guidelines ..................................................................................................................... 22 Appendix C: Booting Windows PE from USB Flash Drive (UFD)............................................................. 23 Additional Resources: ................................................................................................................................. 24 References: ................................................................................................................................................. 24
Page 3
Introduction:
With the release of Vista, Microsoft developed a new method of deploying machines. Part of this new deployment method is the use of file based images called the Windows Imaging format or WIM. With the release or Windows 7 Microsoft has dramatically changed these tools. This document describes how to capture and deploy images using the new tools. Whats the difference between a Ghost image and a WIM image? Ghost doesn't know or care what format the drive or partition is that it is copying: FAT, FAT32, Linux EXT3, HPFS, or NTFS. To it disks are just partitions and partitions are sectors. Ghost will read a sector from the hard disk, compress it and place it into an image file, then continue with the next sector, and the next until it has finished copying the disk or partition, which is why it is called "sector-based" imaging. WIMs are file- and folder- based, and deploy in a mostly non-destructive manner. When you deploy a sector-based image to a hard disk, you destroy whatever partitions sit on that disk; re-imaging a system with Ghost means wiping out the drive. However, when deploying a WIM to a system it means only overwriting whatever files are in the WIM, and no others. As an example, if you had a Windows XP workstation whose hard disk contained a folder named "c:\saveddocs" which held hundreds of documents and you then re-apply the original image to that computer, then you would have a clean copy of the operating system because you overwrote the old one, but the c:\saveddocs folder would still exist in its untouched state. You can also use the WIM format at no cost. All of the WIM tools are a free download from Microsoft as part of the Windows Automated Installation Kit. Ghost, Acronis and other products like them in general all cost money. Originally using WIMs meant you did not have the ability to multicast images, with the release of Server 2008 r2 and Windows Deployment Services (WDS), an add on component of Server 2008 r2, you now have the ability to deploys an image to a large number of client computers concurrently.
Page 4
Requirements: To work through this tutorial you will need the following: Technician Machine with the following: o WAIK (Windows Automated Installation Kit) installed on Technician machine See System requirements for WAIK Based on Windows 7: http://www.microsoft.com/downloads/details.aspx?FamilyID=696dd665-9f764177-a811-39c26d3b3b34&displaylang=en o Technician machine will need a CD/DVD-R/RW o Minimum 2 GB of free disk space to install WAIK and work on Windows PE image. Source system o System configured as desired and ready for image capture. Destination system o System to test the deployment of your image to. o For Windows XP system must be the same or compatible with the source system unless you are using the Universal Imaging Utility or similar. External USB drive or network file share with enough space to store the image, a secondary drive in the source system is also acceptable. Blank CD/DVD-R/RW media, number depends upon method of deployment and image size, or USB flash drive.
Page 5
4. To begin building a Windows PE CD type: copype.cmd x86 c:\winpe_x86 a. Where x86 is the desired system architecture (x86 or amd64) b. And c:\winpe_x86 is your desired working location for Windows PE; this directory must not already exist. 5. Now mount the Windows PE boot image as a folder on your machine so that it may be edited by typing the following: DISM /mount-wim /WimFile:c:\winpe_x86\winpe.wim /Index:1 /MountDir:c:\winpe_x86\mount 6. To copy servicing tools into the mounted PE image, type: xcopy "C:\Program Files\Windows AIK\Tools\Servicing" c:\winpe_x86\mount\Windows /s xcopy "C:\Program Files\Windows AIK\Tools\x86" c:\winpe_x86\mount\Windows /s /Y 7. If you wish to add any additional files such as additional diagnostic tools, Ghost32 or other standalone applications copy them now to: (Remember this is a limited Windows environment it will not have all of the functionality of a normal Windows installation.) c:\winpe_x86\mount this will be the X: drive when booted from the CD and everything here loads into memory, the more you put here the more memory that will be required. c:\winpe_x86\ISO this is the CD itself, put large files like the image files here. WIM Imaging Tutorial v3.0 Page 6
8. Install additional support options: These are not required for image capture or deployment, but if you need the ability to run scripts, use WMI, or any other item listed below it must be explicitly installed before continuing. You also need to install the associated language resource for each package. If you decide you want them later you will have to start the process over. a. Additional font support for the following languages: ja-JP, ko-KR, zh-CN, zh-HK, and zhTW. (Replace <region> with the desired language font) i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-FONTSupport<region>.cab b. HTML Application support. Enables the creation of GUI applications using the Windows Internet Explorer script engine and HTML services. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-HTA.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-HTA.cab c. Microsoft Data Access Component support. Enables queries to SQL servers with Active Directory Objects (ADO). Example usage: building a dynamic Unattend from unique system information. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-MDAC.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-MDAC.cab d. Enables Point-to-Point Protocol over Ethernet (PPPoE) support. Create, connect, disconnect and delete PPPoE connections from Windows PE. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-PPPoE.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-PPPoE.cab e. Windows Script Host (WSH) support. Enables batch file processing using WSH script objects. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-Scripting.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-Scripting.cab f. The Windows Recovery Environment feature package. Provides a recovery platform for automatic system diagnosis and repair and the creation of custom recovery solutions. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-SRT.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-SRT.cab g. Windows Management Instrumentation (WMI) support. A subset of the WMI providers that enables minimal system diagnostics. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-WMI.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-WMI.cab WIM Imaging Tutorial v3.0 Page 7
9.
h. The Windows Deployment Services tools feature package. Includes APIs to enable a multicast scenario with a custom Windows Deployment Services client and Image Capture utility. i. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\WinPE-WDS-Tools.cab ii. dism /image:c:\winpe_x86\mount /Add-Package /PackagePath:c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs\en-us\WinPE-WDSTools.cab Install hardware drivers if necessary before continuing; see Installing Drivers for more info. a. Dism /image:c:\winpe_x86\mount\ /Add-Driver /Driver:<path to individual inf> b. Dism /image:c:\winpe_x86\mount\ /Add-Driver /Driver:<root path to drivers> /Recurse To commit the changes made to Windows PE, type: dism /unmount-wim /mountdir:c:\winpe_x86\mount /commit Export the WIM to remove space held by files no longer in use: Imagex /boot /export c:\winpe_x86\winpe.wim 1 c:\winpe_x86\smallpe.wim Copy the updated and compacted WIM to the ISO folder for creation: copy c:\winpe_x86\smallpe.wim c:\winpe_x86\ISO\sources\boot.wim /Y Create your ISO image: oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\winpe_x86\winpe_x86.iso Using your preferred CD creation software burn the disk image c:\winpe_x86\winpe_x86.iso to CD or CD-RW.
Page 8
Installing Drivers
Drivers can be added to both an online and offline images using different tools. Drvload loads drivers to a booted Windows PE environment while the PEImg tool installs them to the offline image. If the driver requires a reboot to activate you should install it using PEimg, Drvload will ignore the reboot but will not initialize the .sys driver.
Page 9
Capturing a WIM disk images using Windows PE and ImageX: Capture to USB or local drive:
1. Connect your USB or secondary drive to the machine to be imaged. 2. Turn on computer and boot from your newly create Windows PE CD. 3. Windows PE will load and launch a CMD window and run WPEINIT, do not close this window as this will cause the machine to reboot. 4. Verify the USB/secondary drive and the drive to be imaged are both seen, the internal drive should be C:, and the USB or secondary drive D:, but this is not always the case depending upon BIOS configurations. The CD will be the next drive letter after the last partition and the RAM drive where the OS is running from will be X:. As long as you know what is on your drive a simple DIR listing of each drive should suffice to determine the drive letters. For our example we will assume the internal hard drive is C: and the USB/secondary drive is D: 5. To capture the first partition in the CMD window type: imagex /capture c:\ d:\C_Image.wim "Drive C" "My image description" /compress maximum Note: Imagex only captures or deploys partitions; it does not capture full disks. If your disk contains more than one partition you will need to capture each individually. You can capture each partition to the same file by using the following command to append the additional partitions to the existing WIM (assuming D: is the second partition and E: is the USB/secondary drive): imagex /append d:\ e:\C_Image.wim "Drive D" 6. If you will be putting your image on CD/DVD you may need to split the final image into smaller pieces to fit on the media do that now with this command: imagex /split d:\C_Image.wim 650 This will split the image into 650mb chunks on in the same location as the image file. You can split the image into larger or smaller size chunks by changing the 650 to you desired size in megabytes. If you wish to split it to a different location add the path after the source file name: imagex /split d:\c_image.wim d:\splitfile 650 7. You are now ready to deploy your image.
Page 10
Page 11
2. Determine Disk order, type: LIST DISK 3. Select the disk to be imaged, change the number to correspond to your destination, type: SELECT DISK 0 4. To erase everything on the disk type: CLEAN 5. Create primary partition: CREATE PART PRI 6. Select the newly created partition: SELECT PART 1 7. Set partition active: ACTIVE 8. Assign it a drive letter: ASSIGN LETTER=C: 9. Format the drive: FORMAT FS=NTFS LABEL="CDRIVE" QUICK 10. Exit DISKPART: EXIT
Page 12
2. Determine Disk order, type: LIST DISK 3. Select the disk to be imaged, change the number to correspond to your destination, type: SELECT DISK 0 4. To erase everything on the disk type: CLEAN 5. Create primary partition, size in MB: CREATE PART PRI SIZE=1000 6. Select the newly created partition: SELECT PART 1 7. Set partition active: ACTIVE 8. Assign it a drive letter: ASSIGN LETTER=C: Note: Do not assign a driver letter to the System Reserved partition unless you are purposefully restoring it. 9. Format the drive: FORMAT FS=NTFS LABEL="CDRIVE" QUICK 10. Create extended partition: CREATE PART EXT 11. Create logical disk: CREATE PART LOG 12. Select logical disk: SELECT PART 2 13. Format logical partition: FORMAT FS=NTFS LABEL=CDRIVE QUICK Note: Notice you do not have to assign a drive letter to a partition to format it. It formats the currently selected partition. 14. Assign it a drive letter: ASSIGN LETTER=E Note: D: is already assigned to your CD, the letters assigned to the drive are good only for this session of Windows PE and have no bearing anywhere else. Assign letter C if the Windows 7 system reserved partition is the first partition. 15. Exit DISKPART: EXIT
Page 13
DISKPART Scripting:
DISKPART is also scriptable so that you do not have to manually type in all the commands to partition your disk. WARNING: If your disks are not in the order expected when the script is run the wrong disk could be selected and wiped clean thereby losing data. To run a DISKPART script us the following command: DISKPART /s myscript.txt SinglePartition.txt SELECT DISK 0 CLEAN CREATE PART PRI SELECT PART 1 ACTIVE ASSIGN LETTER=C: FORMAT FS=NTFS LABEL="CDRIVE" QUICK EXIT DualPartition.txt SELECT DISK 0 CLEAN CREATE PART PRI SIZE=1000 SELECT PART 1 ACTIVE ASSIGN LETTER=C: FORMAT FS=NTFS LABEL="CDRIVE" QUICK CREATE PART EXT CREATE PART LOG SELECT PART 2 ASSIGN LETTER=D FORMAT FS=NTFS LABEL="CDRIVE" QUICK EXIT DualPartitionWindows7.txt SELECT DISK 0 CLEAN CREATE PART PRI SIZE=100 SELECT PART 1 ACTIVE FORMAT FS=NTFS LABEL="System Reserved" QUICK CREATE PART PRI SELECT PART 2 ASSIGN LETTER=C FORMAT FS=NTFS LABEL="Windows" QUICK EXIT
Page 14
Page 16
Create_Mount.cmd
Creates initial Windows PE image, mounts the image and adds the Imagex servicing tools. Set DestFolder=C:\winpe_x86 Set Arch=x86 copype.cmd %Arch% %DestFolder% DISM /Mount-WIM /WIMFile:%DestFolder%\winpe.wim /Index:1 /MountDir:%DestFolder%\mount xcopy "C:\Program Files\Windows AIK\Tools\Servicing" %DestFolder%\mount\Windows /s xcopy "C:\Program Files\Windows AIK\Tools\%Arch%" %DestFolder%\mount\Windows /s /Y exit
Install_Packages.cmd
Installs additional packages to the image, and then preps the image. (Beware of line wrapping) Set DestFolder=C:\winpe_x86\mount Set PackageSource="c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs" dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-HTA.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-HTA.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-MDAC.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-MDAC.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-PPPoE.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-PPPoE.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-Scripting.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-Scripting.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-SRT.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-SRT.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-WMI.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-WMI.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\WinPE-WDS-Tools.cab dism /image:%DestFolder% /Add-Package /PackagePath:%PackageSource%\en-us\WinPE-WDSTools.cab
Page 17
Install_Drivers.CMD
When calling pass a variable pointing to the driver directory which contains the drivers you wish to install, the given directory will be recursively searched. Usage example: Install_drivers c:\drivers\LAN set Drivers=%1 set DestFolder=c:\winpe_x86\mount DISM /Image:%DestFolder% /Add-Driver /Driver:%Drivers% popd
Commit_Changes.cmd
Commits the changes to the image and removes excess space. Set DestFolder=C:\winpe_x86\Mount DISM /unmount-wim /MountDir:%DestFolder% /commit Imagex /boot /export c:\winpe_x86\winpe.wim 1 c:\winpe_x86\smallpe.wim
Create_ISO.CMD
Copy smaller boot.wim to ISO and create ISO. Set DestFolder=C:\winpe_x86 copy %DestFolder%\smallpe.wim %DestFolder%\ISO\sources\boot.wim /Y oscdimg -n b%DestFolder%\etfsboot.com %DestFolder%\ISO %DestFolder%\winpe_x86.iso
Build_All.CMD
Set Architecture=x86 Set PEDest=c:\winpe_x86 Set MountDir=c:\winpe_x86\mount Set ISOName=winpe_x86.iso Set installmsd=true Set MSDPath=c:\drivers\MSD Set installlan=true Set LanPath=c:\drivers\LAN Set PackageSource=c:\program files\Windows AIK\Tools\PETools\x86\Winpe_FPs Set removeboot=true Set installghost=true Set GhostPath=C:\Program Files\Symantec\Ghost pushd %cd% REM Create and mount PE image call copype.cmd %Architecture% %PEDest% DISM /Mount-WIM /WIMFile:%PEDest%\winpe.wim /Index:1 /MountDir:%MountDir% REM Copy ImageX tools to image xcopy "C:\Program Files\Windows AIK\Tools\Servicing" %MountDir%\Windows /s xcopy "C:\Program Files\Windows AIK\Tools\%Architecture%" %MountDir%\Windows /s /Y REM Install additional Packages in image WIM Imaging Tutorial v3.0
Page 18
dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-HTA.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-HTA.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-MDAC.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-MDAC.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-PPPoE.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-PPPoE.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-Scripting.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-Scripting.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-SRT.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-SRT.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-WMI.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-WMI.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\WinPE-WDS-Tools.cab" dism /image:%PEDest% /Add-Package /PackagePath:"%PackageSource%\en-us\WinPE-WDS-Tools.cab" REM Install Drivers to image if "%installmsd%"=="true" call DISM /Image:%MountDir% /Add-Driver /Driver:%MSDPath% if "%installlan%"=="true" call DISM /Image:%MountDir% /Add-Driver /Driver:%LanPath% REM Install 32-Bit Symantec Ghost tools if "%installghost%"=="true" copy "%GhostPath%\*32.exe" %MountDir%\windows REM Unmount and cleanup image DISM /unmounts-wim /MountDir:%MountDir% /commit imagex /boot /export %PEDest%\winpe.wim 1 %PEDest%\smallpe.wim copy %PEDest%\smallpe.wim %PEDest%\ISO\sources\boot.wim /Y REM Remove 'Press any key to boot message if "%removeboot%"=="true" del /q %pedest%\iso\boot\bootfix.bin REM Create ISO oscdimg -n -b%PEDest%\etfsboot.com %PEDest%\ISO %PEDest%\%ISOName% popd
Page 19
2. Set the default language by using the /Set-AllIntl option with the following syntax. For example: Dism /image:C:\winpe_x86\mount /Set-AllIntl:en-US 3. You can verify the language settings by using the /Get-Intl option. For example, Dism /image:c:\winpe_x86\mount /Get-Intl 4. Continue with further customizations, then run peimg /prep command.
Page 21
You can only use wildcards in the last component in a file path that does not begin with a preceding back slash. For example, myfolder\*.txt You can use a preceding backward slash to limit file- and directory-matching relative to the root directory. For example, if you capture the "c:\" drive with the previous exclusion list, Page 22
\myfolder \folder\subfolder Then ImageX will exclude the following root directories and their files, C:\myfolder c:\folder\subfolder But will not exclude sub-folders of the same name for example, C:\main\myfolder c:\data\folder\subfolder You can override the default exclusion list by using the [ExclusionException] section. For example, [ExclusionException] \pagefile.sys "\System Volume Information" If an explicit [ExclusionException] section is provided in the WIM configuration file, it will always take precedence over the [Exclusion List] section. You cannot override the default compression exclusion list by using the [ExclusionException] section.
Page 23
Additional Resources:
Vista Driverpacks Network and Mass Storage driver packs http://driverpacks.net/driverpacks/windows/vista/x86
References:
http://technet.microsoft.com/en-us/library/dd744548%28WS.10%29.aspx WINPE.CHM Help file installed by WAIK
Page 24