How to Format Your Drive with DiskPart Command in Windows

Microsoft Windows Diskpart Command

Sometimes, storage devices will stop functioning normally, due to incorrectly-configured partition, data corruption or more. It is common to see this problem in Windows, especially with USB flash drives, SD cards and portable hard drives. The drives may not even appear inside the File Explorer, rendering the built-in quick format useless. Fortunately, it can be easily fixed, using the DiskPart command.

DiskPart is an extremely helpful and powerful command-line tool available in Windows 7 to Windows 10. It can be used to manage all the drives (disks and partitions) inside the computer, including clean and re-formatting them.

Microsoft Windows Diskpart Command

Before you fire up DiskPart, you should open the Disk Management Utility and make sure the plugged-in drive is detected. Most importantly, you need to remember the designated disk number, which will be used later in DiskPart. In our example, it is a 8 GB USB flash drive from SanDisk (Disk 4). You can disconnect some of the drives in advance to prevent wiping the data on the wrong drive.

Microsoft Windows Diskpart Command
  • Open the Start Menu and search for Command Prompt (CMD). Right Click on the app and select “Run as administrator”. You can also use DiskPart in Windows PowerShell, if you so desire.
  • Type diskpart and press Enter.
  • Type list disk to show all the connected drives on the computer.
  • Type select disk 4 to choose the problematic drive. (Change the disk number, depends on your particular system and situation)
Microsoft Windows Diskpart Command

You can type list disk again to show all available drives. The selected disk will have an asterisk (*) next to itself in the list. Confirm it is the correct drive by checking in Disk Management Utility and its capacity, before continuing.

Microsoft Windows Diskpart Command
  • Type clean to wipe ALL the data in the drive. Please be reminded that everything on the selected drive will be deleted permanently.
  • Type create partition primary to create a new partition in the cleaned drive.
  • Type format fs=fat32 to format the partition. We use FAT32 as the file system of our USB flash drive. You can change it to exFAT or NTFS, if you are formatting a HDD or SSD. (format fs=exfat or format fs=ntfs)
  • Wait 15 to 30 minutes for it to finish the formatting. Do not remove the drive, unless it is 100% completed.
Microsoft Windows Diskpart Command
  • Type exit to terminate the DiskPart program.
  • DiskPart can do a lot more than cleaning and formatting corrupted drives. You can type help to show all the available commands.

Feel free to leave comments below. Share the article if you enjoy reading it. Follow us on Twitter, Facebook, Instagram and Pinterest.

Support this website simply by shopping on Amazon and Newegg. We will receive small kickbacks, if the above affiliate links are used to make any purchases.


Please enter your comment!
Please enter your name here