How to format a flash drive on the command line
Let’s see how to format a flash drive through the Windows command line in several ways. Sometimes there are situations when it is not possible to format a removable USB drive using other built-in tools of the operating system.
In such a situation, the user needs to format the flash drive through the command line in the Windows operating system. There are several ways that allow you to format a USB flash drive on the command line.
An external USB drive is essentially a drive connected to a computer. The user may need to format the USB flash drive for some reasons:
- the drive must use a different file system;
- to destroy viruses on a flash drive;
- to delete data from removable media.
This guide contains instructions on how to use two options for formatting disks, which differ in approaches to this operation:
- Format – a command designed to format a flash drive or individual hard disk partitions.
- DiskPart is a system utility for working with disks.
In the first case, you can format the entire flash drive, because, as a rule, there is only one partition on a removable USB drive, indicated by the corresponding letter.
The second tool is used in more complex situations where the first method does not lead to a positive result.
When formatting to another file system, all information currently on the disk will be deleted. Take care in advance about moving important data from a flash drive to another safe place on your computer.
In most cases, modern flash drives use the FAT32 and NTFS file systems.
How to format a flash drive to FAT32 or NTFS via command line
First, we use the “format” command, known since the days of DOS, with which you can format a USB flash drive in NTFS or FAT32 on the command line.
Do the following:
- Plug the USB flash drive into the computer’s USB port.
- Look at the drive letter of the connected flash drive.
- Run Command Prompt as Administrator .
- In the command line interpreter window, enter the command:
format X: /fs:fat32 /q - for FAT32 format X: /fs:ntfs /q - for NTFS
“X” – drive letter, “q” – quick format. If the “/q” key is not specified in the command, then a full format will be performed.
- Press the “Enter” key.
- If a message appears in the command prompt window: “Insert a new disk in drive X”, press the “Enter” key again.
You will be prompted to create a volume label (name) that will be displayed in Explorer. This is an optional step. You can type any name on the keyboard, up to 11 characters long. In this example, I named the experimental flash drive the name “vellisa”.
- Specify a volume label or enter nothing, and then press the “Enter” key.
- After formatting is complete, close the Windows Command Prompt window.
The USB flash drive is ready for further use.
How to format a flash drive using the command line in DiskPart – 1 way
Using the DiskPart system tool, you can format a USB flash drive through the Windows command line. This tool is designed to work with computer disks.
Go through the following steps:
- Run command prompt as administrator.
- Type the command “diskpart” and then press “Enter”.
- Type “list volume”, press “Enter”.
The command line interpreter window will display all the drives (volumes or partitions) on your computer. You must select the volume number of the flash drive. Focus on disk size. In this case, I am additionally prompted by the volume label that I assigned to the flash drive when formatting in the previous method.
- Run the command (after entering each command, press the “Enter” key) to select the volume:
select volume X
“X” is the volume number, in this case: “5”
- After selecting the volume, enter the command:
format fs=ntfs quick - for NTFS file system format fs=fat32 quick - for FAT32 file system
- To exit DiskPart, enter the command:
exit
How to format a disk from the command line in DiskPart – 2 way
With the help of DiskPart, we will format the flash drive in a different way. Unlike the previous methods, in this case, all partitions from the flash drive will be deleted, if any, on the USB drive.
This method should work in any case, except for a physical failure of the USB drive.
You will need to do the following:
- Run command prompt as administrator.
- Run the DiskPart utility, run the following commands (press “Enter” to execute each command):
diskpart list disk select disk X
“X” is the number of the disk (flash drive), in this case: “2”.
attributes disk clear readonly clean create partition primary
- Run one of the commands, depending on which file system should be used on the flash drive.
format fs=fat32 quick - for FAT32 format fs=ntfs quick - for NTFS exit
Article Conclusions
If the user has questions about how to format a flash drive using the command line, he can use several methods to solve the problem. Formatting a flash drive can be done using the Windows operating system: by executing the “format” command, or using the built-in DiskPart utility.