This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 740,939 times.
Learn more...
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
- In an elevated command prompt, type "diskpart" and press Enter.
- Type "list disk" and press Enter to find the drive number.
- Type "select disk (drive number)" and press Enter.
- Type "clean" and press Enter.
- Type "create partition primary" and press Enter.
- Type "format fs=exfat" and press Enter.
- Type "assign letter=[letter]" and press Enter.
Steps
-
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.
-
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 -
Type "diskpart" and press ↵ Enter. You'll see some feedback about your computer. Then, the DiskPart utility will initiate.[2]
-
Type "list disk" and press ↵ Enter. In the list, you should be able to determine which listed disk is your USB.[3]
-
Type "select disk [Your disk]" and press ↵ Enter. 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."
-
Type "clean" and press ↵ Enter. 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.
-
Type "create partition primary" and press ↵ Enter. 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.
-
Type "format fs=ntfs" and press ↵ Enter. 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.
-
9Type "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".
-
Type "exit" and press Enter. This will exit the DiskPart program so you can continue using the USB drive to save files or disconnect it from your computer.
-
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.
-
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.
-
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.
-
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.
-
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.
Expert Q&A
Tips
-
If you want your USB drive to work on multiple operating systems, format it as FAT32 or EXFAT.Thanks
Video
References
- ↑ https://www.tomshardware.com/news/format-hard-drive-command-prompt,37632.html
- ↑ https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart
- ↑ https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart
- ↑ https://www.windowscentral.com/how-clean-and-format-storage-drive-using-diskpart-windows-10
- ↑ https://www.tomshardware.com/news/format-hard-drive-command-prompt,37632.html
- ↑ https://www.windowscentral.com/how-clean-and-format-storage-drive-using-diskpart-windows-10
- ↑ https://www.tomshardware.com/news/format-hard-drive-command-prompt,37632.html
- ↑ https://www.tomshardware.com/news/format-hard-drive-command-prompt,37632.html
- ↑ https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell?view=powershell-7.5
About This Article
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.




![Step 5 Type "select disk [Your disk]" and press ↵ Enter.](https://www.wikihow.com/images/thumb/c/ce/Format-a-USB-Using-Cmd-Step-5.jpg/v4-460px-Format-a-USB-Using-Cmd-Step-5.jpg)









