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.
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.
Here are some of the most frequently used Discpart commands:
list disk: Displays a list of all disks available on the system.select disk <disk_number>: Selects the disk to perform operations on.detail disk: Displays detailed information about the selected disk.clean: Removes all partitions or formatting from the selected disk. Use with extreme caution!online disk: Brings a disk that is offline online.offline disk: Takes a disk offline.list partition: Displays a list of partitions on the selected disk.select partition <partition_number>: Selects the partition to perform operations on.create partition primary [size=<size_in_mb>]: Creates a primary partition.create partition extended [size=<size_in_mb>]: Creates an extended partition.create partition logical [size=<size_in_mb>]: Creates a logical partition within an extended partition.delete partition override: Deletes the selected partition. Use with caution!assign letter=<letter>: Assigns a drive letter to the selected partition.remove letter=<letter>: Removes a drive letter from the selected partition.list volume: Displays a list of all volumes on the system.select volume <volume_number>: Selects the volume to perform operations on.detail volume: Displays detailed information about the selected volume.format fs=<filesystem> quick: Formats the selected volume with the specified file system (e.g., NTFS, FAT32).extend [size=<size_in_mb>]: Extends the selected volume to the specified size.shrink desired=<size_in_mb> [minimum=<size_in_mb>]: Shrinks the selected volume.remove quickformat: Disables quick formatting for the selected volume.add-redundancy [ref=<volume_name>]: Creates a mirrored volume (RAID-1).remove-redundancy: Breaks a mirrored volume.Here's a step-by-step example of how to create a new primary partition and format it with NTFS:
diskpart and press Enter.list disk to see available disks.select disk 1 (replace 1 with the actual disk number).create partition primary size=50000 to create a 50GB primary partition.format fs=ntfs quick to format the partition.assign letter=E to assign the drive letter E.exit to leave Discpart.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