Written by
Yuri ZhangSummary: This article introduces DiskPart, lists its core commands, and guides you through two practical use cases — formatting a USB drive and cleaning an SD card- with streamlined steps.
What is DiskPart? What are its commands? How do you use it to format USB drives? How to clean SD cards safely? If you are in the dark about these questions, read on. DiskPart is a tool worth mastering — just don't forget to handle it with care. Let's master this tool by heart.
DiskPart: A command-line tool
DiskPart is built into Windows, so you don't need to download it separately. It comes pre-installed with all modern versions of Windows, including Windows 11/10/8/8.1/7/Server editions. It allows users to perform advanced disk tasks such as:
- Viewing and selecting disks or volumes.
- Creating or deleting partitions.
- Formatting drives.
- Assigning or removing drive letters.
- Convert disks between MBR and GPT.
- Cleaning disks completely
You can refer to the commands list at the end of this article to achieve the correspondent destination.
How to use DiskPart in Windows
Read Format Any New Drive with DiskPart – Crystal-clear Win Guide at your will. DiskPart works with hard drives, SSDs, flash drives, USB drives, SD cards, and other external storage devices. Here's an authentic example to show how to use it. Shared steps are ineluctable if you wish to use DiskPart.
Shared steps: Preparing DiskPart
Before performing any operation, USB or SD card, you always need to:
- Press Win + R, type cmd, right-click it, then select Command Prompt as Administrator.
- To launch DiskPart, type the following command and press Enter:diskpart
- To list available disks, run the command: (Find your USB/SD card from the list, note down its number)list disk
- Then select the target disk using:select disk <number>
These steps are universal for both use cases and are where caution is most needed — selecting the wrong disk could result in permanent data loss. What's more, you can use exit command to exit the utility.
How to format a USB drive using DiskPart
Once your USB drive is selected, copy the following commands one by one and press Enter after each operation:clean
create partition primary
format fs=ntfs quick # or format fs=fat32 quick
assign
exit
This process wipes the USB, creates a new partition, formats it, and assigns it a letter for immediate use.
How to clean an SD card using DiskPart
Once your SD card is selected, run:clean
This is usually enough if you're preparing to reformat it later. But if you want to make it usable immediately, add:create partition primary
format fs=fat32 quick
assign
exit
Use fat32 to maintain compatibility with most digital cameras and devices.
Final Tips:
Double-check the disk number before running destructive commands like clean.
Use format fs=ntfs for computers and large files; use fat32 for smaller storage or device compatibility.
You can always type help within diskpart for command syntax reminders.
Spread these, and when in practice, you will gain a solid foundation of DiskPart.
Common DiskPart commands
Use other commands in the list like exerting the convert gpt command to transform the selected disk into GPT format. Here's a quick cheat sheet of key diskpart commands:
Basic commands
Use these commands to view an overview of the disks, volumes, partitions, and virtual disks currently available on your system.
Command | Description |
list disk | Lists all disks connected to the computer. |
list volume | Lists all volumes (partitions) on the system. |
list partition | Lists partitions on the selected disk. |
list vdisk | Lists virtual disks. |
Note: To select a specific disk, use select disk <n> in the Command Prompt. Similarly, to select a volume or partition, use select volume <n> or select partition <n>. Replace <n> with the appropriate number for your disk, volume, or partition. To select a virtual disk file, use select vdisk <file>.
Disk & partition management
These commands help you manage and modify disk partitions and volumes, including creation, deletion, formatting, and resizing.
Command | Description |
clean | Removes all partitions/volumes on the selected disk. |
clean all | Overwrites every sector on the disk with zeros. |
create partition primary | Creates a primary partition. |
create partition extended | Creates an extended partition. |
create partition logical | Creates a logical partition inside an extended partition. |
delete partition | Deletes the selected partition. |
extend | Extends the selected volume into free space. |
shrink | Shrinks the selected volume. |
format fs=ntfs quick | Formats the selected volume with NTFS (quick format). |
assign | Assigns the next available drive letter to the selected volume. |
remove | Removes the drive letter from the selected volume. |
Disk conversion & configuration
Use these commands to change disk formats or set a partition's bootable status for system boot configurations.
Command | Description |
convert mbr | Converts the selected disk to MBR format. |
convert gpt | Converts the selected disk to GPT format. |
active | Marks the selected partition as active (bootable). |
inactive | Marks the selected partition as inactive. |
Virtual Hard Disk (VHD) management
This is for the pros. VHDs are useful in scenarios like system virtualization, testing environments, disk backups, and running multiple operating systems without physical drives. These commands are for creation, attachment, resizing, and optimization tasks of VHD.
Command | Description |
create vdisk file=<path> | Creates a virtual hard disk file. |
attach vdisk | Mounts the selected VHD file. |
detach vdisk | Unmounts the selected VHD. |
expand vdisk | Increases the size of the selected VHD. |
compact vdisk | Reduces the physical size of a dynamically expanding VHD. |
Share these lists for easy reference and rapid use.
Related articles:
Key Points of Virtualization-Based Security (VBS)
Recover Data Lost by Diskpart Clean or Format on Windows
What Is the Disk in Task Manager and What Does It Represent