다음을 통해 공유


Sample: Configure BIOS/MBR-Based Hard Disk Partitions by Using Windows PE and DiskPart

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

To prepare to deploy a Windows® image to a new computer, you can create partitions by using a DiskPart script. 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.

After you create the partitions, you can apply the Windows images on the newly created partitions.

Configuring Disk Partitions by Using Windows PE and DiskPart Scripts

For image-based deployment, use Windows Preinstallation Environment (Windows PE) to boot the computer, and then use the DiskPart tool to create the partition structures on the destination computers. For more information, see WinPE for Windows 8: Windows PE 5.0.

Note

Windows PE reassigns disk letters alphabetically, starting with the letter C, without regard to the configuration in Windows Setup. This configuration can change based on the presence of different drives, such as USB flash drives.
In these DiskPart examples, the partitions are assigned the letters S, W, and R to avoid drive-letter conflicts. After the computer reboots, Windows PE automatically assigns the letter C to the Windows partition. The system and recovery image partitions do not receive drive letters.

The following steps describe how to partition your hard drives and prepare to apply images. You can use the code in the sections that follow to complete these steps.

To partition hard drives and prepare to apply images

  1. Save the code in the following sections as a text file (CreatePartitions.txt) on a USB flash drive.

  2. Use Windows PE to boot the destination computer.

  3. Use the DiskPart /s F:\CreatePartitions.txt command, where F is the letter of the USB flash drive, to partition the drives.

Sample DiskPart Script: Default Configuration

Save the following code as CreatePartitions.txt, and then use the DiskPart tool to run the script to automate the configuration of the system and Windows partitions.

select disk 0
clean
create partition primary size=350
format quick fs=ntfs label="System"
assign letter="S"
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"
exit

Save the following code as CreatePartitions.txt, and then use the DiskPart tool to run the script to automate the configuration of the system, Windows, and recovery image partitions.

rem == CreatePartitions-BIOS.txt ==
rem == These commands are used with DiskPart to
rem    create three partitions
rem    for a BIOS/MBR-based computer.
rem    Adjust the partition sizes to fill the drive
rem    as necessary. ==
select disk 0
clean
rem == 1. System partition ======================
create partition primary size=350
format quick fs=ntfs label="System"
assign letter="S"
active
rem == 2. Windows partition =====================
rem ==    a. Create the Windows partition =======
create partition primary
rem ==    b. Create space for the recovery image  
shrink minimum=15000
rem          ** Note, adjust the size to match
rem             the size of the recovery image.
rem ==    c. Prepare the Windows partition ====== 
format quick fs=ntfs label="Windows"
assign letter="W"
rem == 3. Recovery image partition ==============
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id=27
list volume
exit

Next Steps

After you create the partitions, you can use a deployment script to apply the Windows images on the newly created partitions. For more information, see Samples: Applying Windows, System, and Recovery Partitions by using a Deployment Script.

See Also

Tasks

Sample: Configure BIOS/MBR-Based Hard Drive Partitions by Using Windows Setup
Sample: Configure UEFI/GPT-Based Hard Drive Partitions by Using Windows PE and DiskPart
Sample: Configure More than Four Partitions on a BIOS/MBR-Based Hard Disk by using Windows PE and DiskPart
Samples: Applying Windows, System, and Recovery Partitions by using a Deployment Script

Concepts

Configure BIOS/MBR-Based Hard Drive Partitions