Microsoft Docs

Discpart Command-Line Utility

The Discpart command-line utility is a text-mode command interpreter that you can use for managing disk, partitions, and volumes on both local and remote computers. To start Discpart, type diskpart at the command prompt.

Overview

Discpart provides a powerful and flexible way to perform disk management tasks directly from the command line. This is particularly useful for scripting, automation, and troubleshooting scenarios where a graphical interface might not be available or practical.

Common Discpart Commands

Here are some of the most frequently used Discpart commands:

Disk Management

Partition Management

Volume Management

Example Usage: Creating and Formatting a New Partition

Here's a step-by-step example of how to create a new primary partition and format it with NTFS:

  1. Open Command Prompt as Administrator.
  2. Type diskpart and press Enter.
  3. Type list disk to see available disks.
  4. Type select disk 1 (replace 1 with the actual disk number).
  5. Type create partition primary size=50000 to create a 50GB primary partition.
  6. Type format fs=ntfs quick to format the partition.
  7. Type assign letter=E to assign the drive letter E.
  8. Type exit to leave Discpart.

Important Considerations

Caution: Commands like clean and delete partition permanently erase data. Always ensure you have backed up any important data before executing these commands. Double-check the disk and partition numbers before proceeding.

For a complete list of Discpart commands and their detailed syntax, please refer to the official Microsoft documentation.

Last updated: October 26, 2023