Deployment error: Windows could not create a partition

I recently encountered problems when deploying Windows (using AutoUnattend.xml) on a test machine.

Installation failed with the message:

Windows_could_not_create_a_partition_on_disk_0

Windows could not create a partition on disk 0. The error occured while applying the unattend answer file’s <DiskConfiguration> setting. Error code: 0x80042565

 

I found these errors in: X:\Windows\Panther\setuperr.log

CreatePartition: Disk 0 doesn't support creation of partitions of the specified type
ApplyDiskOperationUsingService: Failed to correctly apply disk operation of type [0x7]; hr = 0x80042565
CallBack_DiskConfiguration_ApplyUnattend:An error occurred while applying unattend disk configuration; hr = 0x80042565

 

The situation occured because the computer booted in BIOS mode, while the DiskConfiguration specified in AutoUnattend.xml was for UEFI.

(I suspect that similar problems will occur in the opposite situation)

When actively choosing UEFI in the boot menu, it worked as expected.

 

In Windows PE the firmware type can examined by checking the registry key:

HKLM\System\CurrentControlSet\Control\PEFirmwareType

 

If booting in a particular mode is desired, the deployment media can be modified to achieve this:

  • UEFI, not BIOS: Remove bootmgr file from media root.
  • BIOS, not UEFI: Remove efi folder from media root.

 

Discovered the details about identifying firmware type and enforcing booting from a particular firmware type in the article: WinPE: Boot in UEFI or legacy BIOS mode