How to format USB in Windows command?

Formatting a USB drive in Windows using command line is a simple process that can be done in just a few steps. Properly formatting a USB helps prepare the drive for use and can resolve any issues caused by corruption or improper formatting. Using command line provides more options and control compared to using the standard Windows interface.

What is formatting a USB drive?

Formatting a USB drive erases all data on the drive and restructures the drive’s file system. This clears any corruption and prepares the drive to store files again. Formatting removes all files so be sure to back up any needed data before formatting a USB drive.

The most common file systems used for USB drives are FAT32 and NTFS. FAT32 is compatible with both Windows and Mac while NTFS is mainly for Windows. Formatting the drive allows you to choose which file system to use.

Why would you need to format a USB drive?

There are several reasons why formatting a USB drive may be necessary:

  • To remove corruption or errors – If the drive is acting abnormally, formatting can reset it
  • To change file system – Converting between FAT32 and NTFS requires formatting
  • When switching between operating systems – Formatting to compatible file system
  • Before selling or gifting the drive – Erase all personal data
  • To restore full storage capacity – Formatting clears any hidden and system files

Formatting using command line provides more control over these scenarios than using the standard format option in Windows.

How to check USB drive in Windows

Before formatting, you’ll want to first identify the correct drive letter or path of the USB drive you want to format. Here are a few ways to confirm the drive in Windows:

  • Open File Explorer and look for the removable drive. Check the name and drive letter.
  • Open cmd and use the command diskpart. Then list volume and look for the removable drive.
  • Use wmic in cmd to get info: wmic logicaldisk get name, description, filesystem

Be absolutely certain of the correct USB drive before formatting to avoid erasing the wrong drive.

How to format USB on Windows using command line

Here is the overall process to format a USB drive using command line on Windows:

  1. Open a command prompt window as administrator
  2. Type diskpart and press Enter to open DiskPart
  3. Type list disk to list all connected drives
  4. Select the disk to format by typing select disk # (# is disk number)
  5. Type clean to erase and prep drive for formatting
  6. Create a primary partition with create partition primary
  7. Select the partition just created by typing select partition # (# is partition number)
  8. Format the partition using format fs=ntfs quick (or fs=fat32)
  9. Give the drive a letter by typing assign letter=x (use any unused letter)
  10. Exit by typing exit twice

Now the USB drive is formatted and ready to use! The format fs= command determines the file system. Let’s look at the steps in greater details.

Open command prompt as admin

Formatting requires admin access. To open a command prompt as admin:

  1. Press Windows key and type cmd
  2. Right-click on Command Prompt and select Run as Administrator
  3. Click Yes on the UAC prompt

Open DiskPart

DiskPart is a command line disk partitioning tool built into Windows. Type diskpart and press Enter to open it.

List disks

Next, type list disk to show all connected disks and USB drives. Identify the disk # for the drive you want to format.

Select disk

To select the USB drive, type select disk # where # is the disk number from the previous step. This will select the drive to format.

Clean the disk

Use the clean command to completely wipe and erase the drive. This prepares it for a new partition. Type clean and press Enter.

Create primary partition

Now that the disk is prepped, you can create a new primary partition on it by typing create partition primary. This will create a basic partition on the drive.

Select the partition

Use list partition to check the partition number, then select partition # to choose the partition just created to format next.

Format drive

To format the partition, use the format command. For example, format fs=ntfs quick will format to NTFS file system. Or use fs=fat32 for FAT32. Add the quick parameter to do a quick format.

Assign drive letter

If you want the drive to have a letter assigned, use assign letter=x where x is any unused letter like F or Z. This is optional but helpful for easy access.

Exit DiskPart

Finally, type exit twice to close DiskPart and return to the command prompt. The USB drive is now fully formatted and ready to use!

Formatting example

Here is an example showing the full process to format a 16 GB USB drive to NTFS on Windows:

Microsoft Windows [Version 10.0.19045.2486] 
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>diskpart

DiskPart> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          476 GB      0 B        *
  Disk 1    Online          111 GB      0 B
  Disk 2    Online          119 GB      0 B
  Disk 3    Online           14 GB      0 B

DiskPart> select disk 3

Disk 3 is now the selected disk.

DiskPart> clean

DiskPart succeeded in cleaning the disk.

DiskPart> create partition primary

DiskPart succeeded in creating the specified partition.

DiskPart> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary           14 GB    1024 KB

DiskPart> select partition 1
Partition 1 is now the selected partition.

DiskPart> format fs=ntfs quick

 100 percent completed

DiskPart successfully formatted the volume.

DiskPart> assign letter=G

DiskPart> exit

C:\Windows\system32>

This formats the 14 GB USB disk number 3 to NTFS file system and assigns it drive letter G.

Formatting to FAT32 vs NTFS

The main choice when formatting a USB drive is between FAT32 and NTFS file systems. Here is a comparison:

FAT32 NTFS
Compatible with Windows and Mac Mainly compatible with Windows
Max individual file size of 4GB No limit on individual file size
Max partition size of 32GB Maximum partition size of 256TB
No security features like encryption Advanced security features available

In most cases FAT32 is the best choice for USB drives, for compatibility. But if you need larger files or partitions over 32GB, choose NTFS.

Tips for formatting USB drives

Here are some additional tips for formatting USB drives on Windows:

  • Quick format is fine in most cases for basic use. For more damaged drives try full format.
  • Always backup important data before formatting a drive
  • You can reformat between FAT32 and NTFS without data loss
  • Use the proper eject option before physically removing the drive
  • For bootable USBs, use software like Rufus to make them after formatting
  • You can format drives larger than 32GB as FAT32 using third-party tools

Conclusion

Formatting a USB drive using command line is quick and easy with the proper commands. The process involves opening DiskPart, cleaning the disk, creating a new partition, formatting the partition, assigning a drive letter, and exiting DiskPart. Using the format command allows you to choose between FAT32 and NTFS file systems. DiskPart provides more flexibility than the standard Windows format option.

Following the steps in this guide, you can easily format any USB drive on your Windows computer. Just be sure to confirm the correct disk to avoid accidentally formatting the wrong drive. Properly formatting USB drives helps resolve many common issues and prepares the drive for reliable usage going forward.