PDF download Download Article
A step-by-step guide to using commands to reformat a drive
PDF download Download Article

If you're getting errors when trying to format your USB flash drive in Windows File Explorer (such as "Windows was unable to complete the format"), you can still format the drive using the Command Prompt. This wikiHow article will teach you how to erase and reformat your flash drive using the DiskPart tool in CMD and PowerShell using your Windows computer or laptop.

Quick Steps

  1. In an elevated command prompt, type "diskpart" and press Enter .
  2. Type "list disk" and press Enter to find the drive number.
  3. Type "select disk (drive number)" and press Enter .
  4. Type "clean" and press Enter .
  5. Type "create partition primary" and press Enter .
  6. Type "format fs=exfat" and press Enter .
  7. Type "assign letter=[letter]" and press Enter .
Method 1
Method 1 of 2:

Using the Command Prompt

PDF download Download Article
  1. Plug your USB drive into your computer. Plug it into one of the various USB ports on your computer to continue.
    • Normally, you'd format a USB drive by right-clicking it and selecting Format from the menu. You'll only use Command Prompt if that other method does not work.
    • You can also use this method if you can't see the USB drive in File Explorer.
  2. Open Command Prompt as an administrator. To do this, press the Win key on your keyboard and type "cmd" to search for the program. [1]
    • Click Run as Administrator from the results list that appears.
    Advertisement
  3. You'll see some feedback about your computer. Then, the DiskPart utility will initiate. [2]
  4. In the list, you should be able to determine which listed disk is your USB. [3]
  5. From the disk list, you'll need to replace the [Your disk] line with your disk number. [4]
    • For example, if your USB is disk 2, you'd enter "select disk 2."
    • Once the command is accepted, you'll see "[Your disk] is now the selected disk."
  6. Wait a little bit while Command Prompt formats your USB drive. [5]
    • You'll see "DiskPart succeeded in cleaning the disk" when it's finished.
  7. You'll need to do this before you can further format your USB drive. [6]
    • Command Prompt will display "DiskPart succeeded in creating the specified partition" when it's done.
  8. This command will tell your USB drive to format with NTFS format. You can also use FAT32 or exFAT instead by replacing "NTFS" in the command. [7]
    • You'll see "DiskPart successfully formatted the volume" when it's finished.
  9. 9
    Type "assign letter=[letter]" and press Enter . This command will assign a specific letter to your drive. [8]
    • In place of [letter], enter a single letter. For example, you'd enter "assign letter=h".
  10. This will exit the DiskPart program so you can continue using the USB drive to save files or disconnect it from your computer.
  11. Advertisement
Method 2
Method 2 of 2:

Using PowerShell

PDF download Download Article
  1. 1
    Open PowerShell as an administrator. Another way to use commands to format a flash drive or pen drive is to do so with PowerShell. To get started: [9]
    • Press the Windows key on your keyboard.
    • Type powershell .
    • Right-click Windows PowerShell and select Run as Administrator .
    • Click Yes to confirm.
  2. 2
    Type Get-Disk and press Enter . This displays a list of connected drives. The name of your flash drive will appear in the "Friendly name" column, and you'll also see a corresponding number in the "Number" column.
  3. 3
    Clean the drive. To do this, locate the number for the USB drive you want to format, run the command, and confirm. In this example, we'll assume the drive number is 2 –if yours isn't, replace the 2 in this command with that of your USB drive: [10]
    • Clear-Disk -Number 2 -RemoveData
    • When prompted, type Y and press Enter .
  4. 4
    Create a new partition. Once the data is deleted, you will need to add a partition to the USB drive. Again, in this example, we'll use 2 as the drive number, but you'll want to replace the 2 with that of your USB drive. We'll also be assigning the drive a drive letter–we'll use Y in our example, but you can replace it if you'd like:
    • New-Partition -DiskNumber 2 -UseMaximumSize -IsActive -DriveLetter Y
    • Once you run the command, you'll see a message prompting you to format the disk.
  5. 5
    Format the USB drive. Again, we'll use 2 as our drive number example, and Y as our drive letter example. We'll also want to specify the file system to use, such as FAT32 , NTFS, or EXFAT: [11]
    • Format-Volume -DriveLetter Y -FileSystem EXFAT -NewFileSystemLabel USB
    • Replace EXFAT with your preferred file system type if needed.
    • Once the command is finished running, you will be able to use your newly formatted USB drive.
  6. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

      • If you want your USB drive to work on multiple operating systems, format it as FAT32 or EXFAT.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      Video

      About This Article

      Article Summary X

      1. Plug your USB drive into your computer.
      2. Open Command Prompt as an administrator.
      3. Type "diskpart" and press Enter .
      4. Type "list disk" and press Enter .
      5. Type "select disk [Your disk]" and press Enter .
      6. Type "clean" and press Enter .
      7. Type "create partition primary" and press Enter .
      8. Type "format fs=ntfs" and press Enter .
      9. Type "exit" and press Enter .

      Did this summary help you?
      Thanks to all authors for creating a page that has been read 723,301 times.

      Is this article up to date?

      Advertisement