If Windows isn't being run within a VM, full disk images are ill-advised because they're literally not needed unless deploying to multiple machines specifically via FFU images; outside of that, there's literally no use case for partition-level or disk-level images within Windows since Win ≥ XP uses NTFS as the default filesystem (specific to this question, the OS partition is the only partition needing to be imaged).
Due to this, and excluding FFU images, a conventional partition-level or disk-level image containing offset, alignment, block size, etc. isn't required in Windows, and they:
- lack native Windows support and therefore require third-party programs and non-standard Windows boot media
- often lack compression and parity, the main advantages of the Windows Image file format
- WIMs/ESDs can contain multiple images within a relatively small single image file, with data impossible to corrupt provided
/CheckIntegrity and /Verify are always used
- lock the image to that specific partition or drive layout (offset, alignment, block size, etc.)
- often have no data verification, therefore are subject to data corruption
Imaging
PowerShell Mapping | Win ≥ 8: Dism | Win ≤ 7: ImageX
The initial base WIM/ESD does take longer to capture than third-party cloning because parity is built-in to the WIM/ESD file format; after the base image, subsequent appended images take less time. A WIM/ESD can contain multiple images within a relatively small single image file, with data impossible to corrupt provided /CheckIntegrity and /Verify are always used
- WIMs (Windows IMage) can capture an entire partition or individual folders/files
- ESDs (Electronic Software Distribution) can only capture an OS partition and must use
/Compress:Recovery (algorithm is ~33% more efficient than /Compress:Max)
- Windows ≥ 10: Can only be used for PBR [Push-Button Reset] exported images
- Windows ≤ 8.1: Can be used on a bootable Windows install or a PBR image
- Specify exclusions or exceptions by creating a
WimScript.ini config file, with /ScratchDir being required in WinPE since it only has 32MB of scratch [temp] space by default
- To negate the need of
/ScratchDir, see section WinPE/WinRE Customizations
- Even though
/CheckIntegrity (ImageX: /Check) and /Verify do extend the image processing time, they should always be used since they prevent data corruption from occurring within the WIM/ESD
Prerequisites
- Boot to WinRE: (OS partition can only be captured from WinPE)
- Open an Admin terminal:
+R → Open: powershell → Ctrl+Shift+OK
shutdown /r /o /f /t 00
- Troubleshoot → Advanced options → Command Prompt
- Identify the mount point of the offline OS partition: (it's likely not
C:)
DiskPart → either:
- Either:
- Capture a base image:
# Mount Points:
# C: offline OS partition
# Z: partition WIM is being saved to
Windows ≥8: DISM
Dism /Capture-Image /ImageFile:"Z:\Base.wim" /CaptureDir:"C:" /Name:"Windows Backup" /Description:"Base Image 2023.11.17 @ 12:00" /Compress:Max /CheckIntegrity /Verify /ScratchDir:"Z:"
Windows XP ≤ 7: ImageX
ImageX /Capture "C:" "Z:\Base.esd" "Windows Backup" "Base Image 2023.11.17 @ 12:00" /Compress:Recovery /Check /Verify /ScratchDir:"Z:"
- Mechanical HDD: since compression takes longer if using
/Compress:<Max||Recovery>, if time's an issue, it's more efficient to use /Compress:Fast, exporting the index later using Max or Recovery
- Append an image to an existing WIM:
# Mount Points
# C: offline OS partition
# Z: partition containing the WIM
Windows ≥8: DISM
Dism /Append-Image /ImageFile:"Z:\Base.wim" /CaptureDir:"C:" /Name:"Windows Backup" /Description:"Appended Image 2023.11.17 @ 12:00" /CheckIntegrity /Verify /ScratchDir:"Z:"
Windows XP ≤ 7: ImageX
ImageX /Append "C:" "Z:\Base.esd" "Windows Backup" "Appended Image 2023.11.17 @ 12:00" /Compress:Recovery /Check /Verify /ScratchDir:"Z:"
- Compression is locked to the value set when the base image was captured
- Individual indexes can be deleted via
/Delete-Image or exported to their own WIM/ESD via /Export-Image
- Format the offline OS partition:
DiskPart → lis dis → sel dis # → lis par → sel par #
- Verify correct partition selected:
det par
format fs=ntfs quick label=OS → det par
- If mount point [
Ltr] still exists → exit; if not: assign letter=O → exit
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
* Volume 8 O OS NTFS Partition 300 GB Healthy Boot
/Get-ImageInfo to ensure correct index [image] is being applied:
# Windows ≥8: DISM
Dism /Get-ImageInfo /ImageFile:"Z:\Base.wim"
Windows XP ≤ 7: ImageX
ImageX /Info "Z:\Base.wim"
- Apply image to the offline OS partition:
# Mount Points
# C: offline OS partition image is being applied to
# Z: partition containing the WIM
Windows ≥8: DISM
Dism /Apply-Image /ImageFile:"Z:\Base.wim" /Index:1 /ApplyDir:"C:" /CheckIntegrity /Verify /ScratchDir:"Z:"
Windows XP ≤ 7: ImageX
ImageX /Apply "Z:\Base.wim" 1 "C:" /Check /Verify /ScratchDir:"Z:"
BootRec must be run prior to exiting WinPE/WinRE:
- BIOS:
BootRec /FixMBR && BootRec /FixBoot && BootRec /RebuildBCD
- UEFI:
::# With existing bootable EFI partition:
BootRec /FixMBR && BootRec /RebuildBCD
::# Without existing bootable EFI partition:
::# Create EFI directories and enter:
MkDir "Y:\EFI\Microsoft\Boot"
Cd /d "Y:\EFI\Microsoft\Boot"
::# Create EFI boot structure:
BootRec /Fixboot
::# If Access Denied error occurs (C: is applied image):
BcdBoot C:\Windows /s Y: /f UEFI
::# Resolve any other boot issues:
BootRec /FixMBR && BootRec /RebuildBCD
Appended WIM Example
PS $ ls -file "Z:\WIM"
Directory: Z:\WIM
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2023.09.05 00:33:46 40,193,295,546B Base.wim
-a---- 2023.09.05 00:07:12 568B Dism.cmd
-a---- 2023.09.05 00:09:51 97B WimScript.ini
PS $ Dism /Get-ImageInfo /ImageFile:"Z:\WIM\base.wim"
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Details for image : Z:\WIM\base.wim
Index : 1
Name : Alienware 18: Windows 11
Description : v22H2: Base (Drivers & Updates Only)
Size : 48,259,986,179 bytes
Index : 2
Name : Alienware 18: Windows 11
Description : v22H2: Programs Installed (Customizations Applied)
Size : 74,666,504,006 bytes
PS $ Dism /Get-ImageInfo /ImageFile:"Z:\WIM\base.wim" /Index:1
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Details for image : Z:\WIM\base.wim
Index : 1
Name : Alienware 18: Windows 11
Description : v22H2: Base (Drivers & Updates Only)
Size : 48,259,986,179 bytes
WIM Bootable : No
Architecture : x64
Hal : COMPUTER\Generic
Version : 10.0.22621
ServicePack Build : 2215
ServicePack Level : 0
Edition : Professional
Installation : Client
ProductType : WinNT
ProductSuite : Terminal Server
System Root : WINDOWS
Directories : 48508
Files : 195745
Created : 2023.08.28 - 22:09:33
Modified : 2023.08.28 - 22:09:34
Languages : en-US (Default)
PS $ Dism /Get-ImageInfo /ImageFile:"Z:\WIM\base.wim" /Index:2
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Details for image : Z:\WIM\base.wim
Index : 2
Name : Alienware 18: Windows 11
Description : v22H2: Programs Installed (Customizations Applied)
Size : 74,666,504,006 bytes
WIM Bootable : No
Architecture : x64
Hal : COMPUTER\Generic
Version : 10.0.22621
ServicePack Build : 2215
ServicePack Level : 0
Edition : Professional
Installation : Client
ProductType : WinNT
ProductSuite : Terminal Server
System Root : WINDOWS
Directories : 60460
Files : 275154
Created : 2023.09.04 - 23:30:09
Modified : 2023.09.04 - 23:30:10
Languages : en-US (Default)
Configure New Drive
DiskPart:
::# List disks:
Lis Dis
::# Select OS drive # WIM is being applied to:
Sel Dis #
::# Wipe partition table (assumes no data on drive is being preserved)
Clean
UEFI:
Convert Gpt
- Create boot partition:
- Create System partition:
- Rest of the drive as the System partition:
If C: can't be assigned, change 3 & 5 to another letter
- Additional partitions after the [200GB] System partition:
If storing User Data directories on a partition other than C:\ (recommended), max size required is ~300GB (multiply size wanted by 1024: 200*1024=204800)
- Create WinRE partition: (should have 320MB free to allow for future WIM size increases)
- BIOS:
Shrink Desired=665 Minimum=650
Cre Par Pri id=27
Format Quick Fs=NTFS Label=WinRE
- UEFI:
Shrink Desired=665 Minimum=650
Cre Par Pri Id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
Format Quick Fs=NTFS Label=WinRE
Gpt Attributes=0x8000000000000001
- Resolve any boot issues: (once WIM has been applied)
- BIOS:
BootRec /FixMBR && BootRec /FixBoot && BootRec /RebuildBCD
- UEFI:
::# With existing bootable EFI partition:
BootRec /FixMBR && BootRec /RebuildBCD
::# Without existing bootable EFI partition:
::# Create EFI directories and enter:
MkDir "Y:\EFI\Microsoft\Boot"
Cd /d "Y:\EFI\Microsoft\Boot"
::# Create EFI boot structure:
BootRec /Fixboot
::# If Access Denied error occurs (C: is applied image):
BcdBoot C:\Windows /s Y: /f UEFI
::# Resolve any other boot issues:
BootRec /FixMBR && BootRec /RebuildBCD
- Remove EFI mountpoint and Reboot:
DiskPart
Sel Vol Y
Remove
Exit
WinPE/WinRE Customizations
To increase the temp space available in WinPE/WinRE, negating the need for /ScratchDir:
- Open an Admin terminal:
+R → Open: powershell → Ctrl+Shift+OK
-
## <InstallUSB>: drive letter for the Install USB ##
Create working directory:
MkDir "C:\Mount"
Get correct image index (Windows Setup is usually #2):
Dism /Get-ImageInfo /ImageFile:"<InstallUSB>:\sources\boot.wim"
Mount WinPE Windows Setup WIM:
Dism /Mount-Image /ImageFile:"<InstallUSB>:\sources\boot.wim" /Index:2 /MountDir:"C:\Mount"
Load WinPE SYSTEM hive:
Reg Load HKLM\WinPE "C:\Mount\Windows\System32\config\SYSTEM"
Show hidden files:
Reg Add HKLM\WinPE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1
Reg Add HKLM\WinPE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1
Show file extensions:
Reg Add HKLM\WinPE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0
Unload Hive:
Reg Unload HKLM\WinPE
Set WinPE default temp space to 512MB:
Dism /Set-ScratchSpace:512 /Image:"C:\Mount"
Unmount WinPE Windows Setup WIM:
Dism /Unmount-Image /MountDir:"C:\Mount" /Commit
Cleanup:
RmDir /s /q "C:\Mount"
- Open an Admin terminal:
+R → Open: powershell → Ctrl+Shift+OK
- Mount WinRE partition:
DiskPart → lis vol → sel vol # → det vol → assign letter=W → exit
-
# Create working directory:
MkDir "C:\Mount"
Mount WinRE WIM:
Dism /Mount-Image /ImageFile:"W:\Recovery\WindowsRE\winre.wim" /Index:1 /MountDir:"C:\Mount"
Load WinRE SYSTEM hive:
Reg Load HKLM\WinRE "C:\Mount\Windows\System32\config\SYSTEM"
Show hidden files:
Reg Add HKLM\WinRE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1
Reg Add HKLM\WinRE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1
Show file extensions:
Reg Add HKLM\WinRE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0
Unload Hive:
Reg Unload HKLM\WinRE
Set WinRE default temp space to 512MB:
Dism /Set-ScratchSpace:512 /Image:"C:\Mount"
Unmount WinRE WIM:
Dism /Unmount-Image /MountDir:"C:\Mount" /Commit
Cleanup:
RmDir /s /q "C:\Mount"
- Unmount WinRE partition:
DiskPart → sel vol W → remove → exit