次の方法で共有


Sample: Configure UEFI/GPT-Based Hard Drive 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 PC, you can create partitions by using a DiskPart script. This topic provides examples of how to configure disk partitions for a PC that is based on Unified Extensible Firmware Interface (UEFI) firmware and whose disks use a GUID partition table (GPT). This topic covers the following partition configurations:

  • Default configuration. Includes a Windows Recovery Environment (Windows RE) Tools partition, a system partition, a Microsoft® Reserved Partition (MSR) partition, and a Windows partition. The following diagram shows this configuration.

  • Recommended configuration. Includes a Windows RE Tools partition, a system partition, an MSR partition, a Windows partition, and a recovery image partition. The following diagram shows this configuration.

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

In this topic:

  • Configuring Disk Partitions by Using Windows PE and DiskPart Scripts

  • Sample DiskPart Script: Default Configuration

  • Sample DiskPart Script: Recommended Configuration

  • Providing Additional Protection for Windows RE Tools and Recovery Image Partitions

  • Next Steps

Configuring Disk Partitions by Using Windows PE and DiskPart Scripts

For image-based deployment, use Windows Preinstallation Environment (Windows PE) to boot the PC. Then, use the DiskPart tool to create the partition structures on your destination PCs. 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, including USB flash drives.
In these DiskPart examples, the partitions are assigned the letters T, S, W, and R to avoid drive-letter conflicts. After the PC reboots, Windows PE automatically assigns the letter C to the Windows partition. The system partition, the Windows RE tools partition, and the recovery image partition 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 PC.

  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 that automates the configuration of the System, MSR, and Windows partitions.

select disk 0
clean
convert gpt
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
create partition efi size=100
rem == Note: for Advanced Format Generation One drives, change to size=260.

format quick fs=fat32 label="System"
assign letter="S"
create partition msr size=128
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"

Save the following code as CreatePartitions.txt, and then use the DiskPart tool to run the script that automates the configuration of the Windows RE Tools partition, the System, MSR, Windows, and recovery image partitions.

rem == CreatePartitions-UEFI.txt ==
rem == These commands are used with DiskPart to
rem    create five partitions
rem    for a UEFI/GPT-based PC.
rem    Adjust the partition sizes to fill the drive
rem    as necessary. ==
select disk 0
clean
convert gpt
rem == 1. Windows RE tools partition ===============
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
rem == 2. System partition =========================
create partition efi size=100
rem    ** NOTE: For Advanced Format 4Kn drives,
rem               change this value to size = 260 ** 
format quick fs=fat32 label="System"
assign letter="S"
rem == 3. Microsoft Reserved (MSR) partition =======
create partition msr size=128
rem == 4. Windows partition ========================
rem ==    a. Create the Windows partition ==========
create partition primary 
rem ==    b. Create space for the recovery image ===
shrink minimum=15000
rem       ** NOTE: Update this size to match the size
rem                of the recovery image           **
rem ==    c. Prepare the Windows partition ========= 
format quick fs=ntfs label="Windows"
assign letter="W"
rem === 5. Recovery image partition ================
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit

Providing Additional Protection for Windows RE Tools and Recovery Image Partitions

If you use the recommended DiskPart script, end users do not see the Windows RE Tools partition and the recovery image partition in File Explorer. However, they can see and remove the recovery image partition by using disk management tools.

If you want to prevent end users from removing partitions by using disk management tools, you can add the following DiskPart command to the script when you create a partition.

gpt attributes=0x8000000000000001

This DiskPart command combines the GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001) and GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000) attributes. For more information, see DiskPart: GPT.

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 UEFI/GPT-Based Hard Drive Partitions by Using Windows Setup
Sample: Configure BIOS/MBR-Based Hard Disk Partitions by Using Windows PE and DiskPart
Samples: Applying Windows, System, and Recovery Partitions by using a Deployment Script

Concepts

Configure UEFI/GPT-Based Hard Drive Partitions