Skip to content

Windows ISO WIM Splitting and AutoUnattend

buntatoes edited this page Nov 28, 2026 · 1 revision

Windows ISO, WIM Splitting, and AutoUnattend

Modern Windows 10 and Windows 11 installation ISOs ship a sources/install.wim archive that frequently exceeds FAT32's 4 GiB (4,294,967,295-byte) single-file limit. Instead of formatting NTFS and bundling a third-party UEFI NTFS driver (which breaks strict UEFI Secure Boot on many machines unless unsigned drivers are allowed), Cinderboot builds a 100% Microsoft-native GPT + FAT32 UEFI USB that boots directly under strict Secure Boot with zero third-party bootloaders.


Windows GPT + FAT32 Pipeline (WriteISOFAT32)

Implemented in internal/flash/iso_fat32.go, the windows-fat32 (and iso-fat32) pipeline performs every step in pure Go:

flowchart TD
    ISO["Windows 10/11 ISO (UDF 1.02 or ISO9660)"]
    Walk["Enumerate Entries & Validate Drive Capacity (+64 MiB headroom)"]
    GPT["Write Protective MBR + Single 1 MiB-Aligned GPT Partition (GPTTypeBasicData)"]
    FAT["Format FAT32 Volume (FAT32Writer)"]
    Loop["For Each Entry in ISO"]
    Small["File <= 4 GiB - 1 Byte -> Stream Directly to FAT32"]
    WIM["File > 4 GiB and ends with .wim -> Lossless Streaming Split (.swm)"]
    Auto["Optional: Generate & Write /autounattend.xml"]
    Close["Flush Directories, FAT1/FAT2, FSInfo, Boot/Backup Boot Sectors & Sync()"]

    ISO --> Walk --> GPT --> FAT --> Loop
    Loop --> Small --> Auto
    Loop --> WIM --> Auto
    Auto --> Close
Loading

Key pipeline details:

  • UDF 1.02 First: image.OpenImageFS tries OpenUDF before OpenISO9660, because official Microsoft oscdimg ISOs store full paths and >4 GiB install.wim files in UDF 1.02.
  • Headroom Check: Verifies totalBytes + 64 MiB <= diskSize before writing.
  • Volume Label: Uses --label if specified, otherwise the ISO's UDF/ISO9660 volume label, otherwise CINDERBOOT (sanitized to 11 uppercase FAT32-safe characters).
  • Non-WIM Files >4 GiB: If a file larger than 4,294,967,295 bytes is not a .wim archive (for instance, a solid .esd or other oversized file), Cinderboot fails clearly rather than silently truncating it.

Pure-Go Lossless .wim to .swm Splitting (internal/wim)

Windows Setup natively recognizes spanned WIM archives (sources/install.swm, sources/install2.swm, sources/install3.swm, ...) on FAT32 partitions. Cinderboot's pure-Go splitter (internal/wim/split.go) produces spec-compliant .swm files without decompressing or recompressing any LZX/XPRESS payloads and without using temporary disk space.

How Splitting Works

  1. Header Validation: Reads the 208-byte MSWIM\0\0\0 header (wimHeaderSize = 208) via io.ReaderAt directly out of the ISO's UDF extents.
    • Rejects solid ESD archives (version == 0x00000E00) with ErrSolidESD, because solid compressed chunks cannot be split without full decompression and recompression.
  2. Lookup Table & XML Loading: Loads the 50-byte-per-entry resource lookup table (wimResEntrySize = 50) and XML metadata into memory (typically only a few MiB).
  3. Metadata vs. Data Partitioning:
    • Separates metadata resources (resFlagMetadata = 0x02) from data resources.
    • Places all metadata resources into Part 1 first (required by Windows Setup), updating bootMetadata and bootIndex offsets accordingly.
    • Packs data resources greedily across Part 1..N while keeping each part's total size (208-byte header + resource payloads + part lookup table + XML metadata) under DefaultMaxPartSize = 3,800 MiB (safely below FAT32's 4 GiB limit).
  4. Zero-Temp-Disk Streaming via io.Pipe:
    • Because each planned PartSpec computes its exact final byte size (TotalSize) up front, flash/iso_fat32.go knows the exact FAT32 cluster chain length before writing byte 0.
    • For each part, wim.Split invokes the consumer with (partNum, totalParts, exactSize, streamFn).
    • iso_fat32.go connects streamFn to FAT32Writer.WriteFileCtx over an in-memory io.Pipe(), streaming 1 MiB chunks directly from the source ISO into the USB drive's FAT32 clusters.
  5. Spanned Header & Naming Convention:
    • Sets FLAG_HEADER_SPANNED (0x00000008), writes partNumber and totalParts, rewrites every entry's offset and partNumber, clears the integrity table on split parts, and appends each part's lookup table and XML metadata.
    • Names output files using Microsoft Windows Setup's exact convention (PartFileName):
      • Part 1 → sources/install.swm
      • Part 2 → sources/install2.swm
      • Part 3 → sources/install3.swm (and so on)

Note

If sources/install.wim (or sources/install.esd) is ≤ 4,294,967,295 bytes, no splitting is needed and the file is copied verbatim into sources/ on the FAT32 partition.


Windows 10/11 autounattend.xml Customization (internal/unattend)

When any Windows customization option is enabled (in the UI or CLI), unattend.Generate builds a UTF-8 Microsoft Windows Setup autounattend.xml document, validates its XML syntax with Go's encoding/xml decoder, and writes it to the USB root directory (/autounattend.xml). If no options are enabled, no autounattend.xml file is written.

Options & Generated Settings

CLI Flag JSON Field (unattend.*) Setup Pass & Component Exact Action Written to autounattend.xml
--win-bypass-req bypass_requirements windowsPE / Microsoft-Windows-Setup (RunSynchronous) Sets REG_DWORD = 1 under HKLM\SYSTEM\Setup\LabConfig for BypassTPMCheck, BypassSecureBootCheck, BypassRAMCheck, and BypassStorageCheck
--win-bypass-msa bypass_msa specialize / Microsoft-Windows-Deployment (RunSynchronous) Sets HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE\BypassNRO = 1 (REG_DWORD)
--win-no-bitlocker disable_bitlocker specialize / Microsoft-Windows-Deployment (RunSynchronous) Sets HKLM\SYSTEM\CurrentControlSet\Control\BitLocker\PreventDeviceEncryption = 1 (REG_DWORD)
--win-skip-privacy skip_privacy oobeSystem / Microsoft-Windows-Shell-Setup (OOBE) Sets HideEULAPage=true, HideLocalAccountScreen=false, HideOnlineAccountScreens=true, HideWirelessSetupInOOBE=true, ProtectYourPC=3
--win-user <name> local_username oobeSystem / Microsoft-Windows-Shell-Setup (UserAccounts/LocalAccounts) Adds a local account in the Administrators group with an empty initial password (PlainText=true)

Security & Input Sanitization Details

  • XML Escaping: All descriptions, commands, and usernames are escaped through xml.EscapeText.
  • Username Sanitization (sanitizeLocalUsername): Trims whitespace, truncates to 20 characters, and strips any character outside [A-Za-z0-9\-_ ].
  • Schema Validation: Every generated document is parsed token-by-token through xml.NewDecoder before returning; malformed XML causes the flash step to fail safely.

Warning

When --win-user is set, the generated local Administrator account is created with a blank password so first-boot OOBE completes unattended. Set a strong password immediately after Windows finishes installing.

Clone this wiki locally