Partager via


Sample: Configure BIOS/MBR-Based Hard Drive Partitions by Using Windows Setup

Applies To: Windows 8, Windows 8.1, Windows Server 2012, Windows Server 2012 R2

You can add answer-file settings to automatically configure disk partitions during a Windows® installation. This topic describes how to configure disk partitions for a BIOS-based and master boot record (MBR)–based computer, as described in Configure BIOS/MBR-Based Hard Drive Partitions. This topic covers the following partition configurations:

  • Default configuration. Includes a system partition and a Windows partition. The following diagram shows the default configuration.

  • Recommended configuration. Includes a system partition, a Windows partition, and a recovery image partition. The following diagram shows the recommended configuration.

Manually select the default partition configuration

For new installations, Windows Setup prompts you to configure your partitions. If you select the default configuration, Windows Setup creates this partition configuration when the following conditions are true:

  • The computer does not already have a Windows partition. When you upgrade Windows from an earlier version, Windows Setup does not change the arrangement of your partitions.

  • The computer does not already have a system partition.

  • The computer does not already have three partitions.

  • The computer has sufficient disk space for the partitions.

Example: Automatically install the default partition configuration

To automate the configuration of system and Windows partitions, add the following settings to an answer file.

Microsoft-Windows-Setup\DiskConfiguration\Disk

DiskID = 0
WillWipeDisk = true

Microsoft-Windows-Setup\DiskConfiguration\Disk\
CreatePartitions\CreatePartition

Order = 1
Size = size in megabytes (for example, 350)
Type = Primary

Microsoft-Windows-Setup\DiskConfiguration\Disk\
CreatePartitions\CreatePartition

Extend = true
Order = 2
Type = Primary

Microsoft-Windows-Setup\DiskConfiguration\Disk\
ModifyPartitions\ModifyPartition

Active = true
Format = NTFS
Label = System
Order = 1
PartitionID = 1

Microsoft-Windows-Setup\DiskConfiguration\Disk\
ModifyPartitions\ModifyPartition

Format = NTFS
Label = Windows
Letter = C
Order = 2
PartitionID = 2

Microsoft-Windows-Setup\ImageInstall\OSImage\InstallTo

DiskID = 0
PartitionID = 2

XML Example

<DiskConfiguration>

  <Disk wcm:action="add">
    <DiskID>0</DiskID> 
    <WillWipeDisk>true</WillWipeDisk> 
    <CreatePartitions>
      <!-- System partition -->
      <CreatePartition wcm:action="add">
        <Order>1</Order> 
        <Type>Primary</Type> 
        <Size>350</Size> 
      </CreatePartition>

      <!-- Windows partition -->
      <CreatePartition wcm:action="add">
        <Order>2</Order> 
        <Type>Primary</Type> 
        <Extend>true</Extend> 
      </CreatePartition>
    </CreatePartitions>

    <ModifyPartitions>
      <!-- System partition -->
      <ModifyPartition wcm:action="add">
        <Order>1</Order> 
        <PartitionID>1</PartitionID> 
        <Label>System</Label> 
        <Letter>S</Letter> 
        <Format>NTFS</Format> 
        <Active>true</Active> 
      </ModifyPartition>

      <!-- Windows partition -->
      <ModifyPartition wcm:action="add">
        <Order>2</Order> 
        <PartitionID>2</PartitionID> 
        <Label>Windows</Label> 
        <Letter>C</Letter> 
        <Format>NTFS</Format> 
      </ModifyPartition>
    </ModifyPartitions>
  </Disk>
  <WillShowUI>OnError</WillShowUI> 
</DiskConfiguration>

<ImageInstall>
  <OSImage>
    <InstallTo>
      <DiskID>0</DiskID> 
      <PartitionID>2</PartitionID> 
    </InstallTo>
  </OSImage>
</ImageInstall>

To automate the configuration of system, Windows, and recovery image partitions, add the following settings to an answer file.

Microsoft-Windows-Setup\DiskConfiguration\Disk

DiskID = 0
WillWipeDisk = true

Microsoft-Windows-Setup\DiskConfiguration\Disk\
CreatePartitions\CreatePartition

Order = 1
Size = size in megabytes (for example, 350)
Type = Primary

Microsoft-Windows-Setup\DiskConfiguration\Disk\
CreatePartitions\CreatePartition

Order = 2
Size = size in megabytes (for example, 75000)
Type = Primary

Microsoft-Windows-Setup\DiskConfiguration\Disk\
CreatePartitions\CreatePartition

Order = 3
Size = size in megabytes (for example, 15000)
Type = Primary

Microsoft-Windows-Setup\DiskConfiguration\Disk\
ModifyPartitions\ModifyPartition

Active = true
Format = NTFS
Label = System
Order = 1
PartitionID = 1

Microsoft-Windows-Setup\DiskConfiguration\Disk\
ModifyPartitions\ModifyPartition

Format = NTFS
Label = Windows
Letter = C
Order = 2
PartitionID = 2

Microsoft-Windows-Setup\DiskConfiguration\Disk\
ModifyPartitions\ModifyPartition

Format = NTFS
Label = Recovery
Order = 3
PartitionID = 3

Microsoft-Windows-Setup\ImageInstall\OSImage\InstallTo

DiskID = 0
PartitionID = 2

XML Example

<DiskConfiguration>

  <Disk wcm:action="add">
    <DiskID>0</DiskID> 
    <WillWipeDisk>true</WillWipeDisk> 
    <CreatePartitions>

      <!-- System partition -->
      <CreatePartition wcm:action="add">
        <Order>2</Order> 
        <Type>Primary</Type> 
        <Size>350</Size> 
      </CreatePartition>

      <!-- Windows partition -->
      <CreatePartition wcm:action="add">
        <Order>3</Order> 
        <Type>Primary</Type> 
        <Size>75000</Size> 

      </CreatePartition>
    </CreatePartitions>

      <!-- Recovery image partition -->
      <CreatePartition wcm:action="add">
        <Order>1</Order> 
        <Type>Primary</Type> 
        <Size>15000</Size> 
      </CreatePartition>

    <ModifyPartitions>

      <!-- System partition -->
      <ModifyPartition wcm:action="add">
        <Order>1</Order> 
        <PartitionID>1</PartitionID> 
        <Label>System</Label> 
        <Letter>S</Letter> 
        <Format>NTFS</Format> 
        <Active>true</Active> 
      </ModifyPartition>

      <!-- Windows partition -->
      <ModifyPartition wcm:action="add">
        <Order>2</Order> 
        <PartitionID>2</PartitionID> 
        <Label>Windows</Label> 
        <Letter>C</Letter> 
        <Format>NTFS</Format> 
      </ModifyPartition>

      <!-- Recovery image partition -->
      <ModifyPartition wcm:action="add">
        <Order>3</Order> 
        <PartitionID>3</PartitionID> 
        <Label>Recovery</Label> 
        <Format>NTFS</Format> 
        <TypeID>0x27</TypeID>
      </ModifyPartition>

    </ModifyPartitions>
  </Disk>
  <WillShowUI>OnError</WillShowUI> 
</DiskConfiguration>

<ImageInstall>
  <OSImage>
    <InstallTo>
      <DiskID>0</DiskID> 
      <PartitionID>2</PartitionID> 
    </InstallTo>
  </OSImage>
</ImageInstall>

See Also

Tasks

Sample: Configure BIOS/MBR-Based Hard Disk Partitions by Using Windows PE and DiskPart
Sample: Configure More than Four Partitions on a BIOS/MBR-Based Hard Disk by using Windows Setup
Sample: Configure UEFI/GPT-Based Hard Drive Partitions by Using Windows Setup

Concepts

Configure BIOS/MBR-Based Hard Drive Partitions