How to Format Pen Drive using CMD?

November 16, 2018

You may don’t know to format USB drive like pen drive, SD card when it is write-protected or damaged. If so, read this paper to learn how to format pen drive or SD card using CMD.

My pen drive not formatting

“My friend gave me a 32GB pen drive. When I tried to format it to NTFS in File Explore, I just got the message Windows was unable to complete the format. I entered Disk Management to format the USB drive, but still failed. Is my pen drive corrupted? How can I format it to NTFS successfully?”

Format pen drive using CMD

If you are in the situation mentioned above, you may find that your pen drive becomes RAW in Disk Management. That is to say, the file system of the pen drive partition is corrupted or damaged.

RAW Pen Drive

In such condition, you can format your pen drive, SD card or external hard drive using CMD. See the detailed steps given below (Take formatting pen drive in Windows 7 as an example)

Note: Formatting pen drive will remove all data on it, thus you can make a backup at first, if there is any necessary files on it.

1. In the Search box, type “CMD”, right click Command Prompt among pop-up results and select Run as administrator to open Command Prompt.

2. In the appearing window, type diskpart and hit Enter.

3. Run the following commands:

  • list disk (all disks connected to your computer will be listed)

  • select disk n (“n” is the number of your pen drive)

  • clean

  • create partition primary

  • select partition 1

  • format fs=ntfs (you can replace ntfs with exfat or fat32 if you want )

  • assign drive letter f (“f” can be replaced if you want)

Format Pen Drive using CMD

Then, you can type “exit” and hit Enter to close this window.

If you receiving the message that Diskaprt has encountered an error: the media is write-protected while running “clean” command, you can run these commands: list disk> select disk n>attributes disk clear readonly, to disable write protection from pen drive at first.

Format pen drive using format tool

If you are not familiar with Command Prompt, it is not advised to format pen drive using CMD as the operations mentioned above are irreversible and you may format wrong disk, which will cause data loss. If you want to format the partition larger than 32GB, Diskpart utility can’t help you. At this point, this excellent and powerful free format tool – AOMEI Partition Assistant Standard will be your best choice.

It is designed with intuitive graphic user interface, allowing you to make operations simply and effectively. Breaking the imitation of 32GB, enabling you to format 64GB, 128GB even larger drive to FAT32; Besides, it offers you various file systems covering NTFS, exFAT, FAT32, Ext4, Ex3 and Ext2, making it possible to format the drive for other operating system like Linux.

PS.:AOMEI Partition Assistant Standard is suitable for Windows 7/8/8.1/10, XP and Vista.

Step 1. Free Download AOMEI Partition Assistant, run and open it. Right click the partition on the pen drive and choose “Format Partition”.

Format Pen Drive using CMD Alternative

Step 2. In the pop-up dialogue, choose a file system based on your demand. (For example, if you need to format the drive with the file system compatible with Mac and Windows, exFAT can be your choice.)

Format Pen Drive to exFAT

Step 3. Return to the main interface. Click “Apply” and “Proceed” after confirming operation.


After a while, you will have formatted your pen drive to exFAT or other file system in a success. Enter Disk Management, you can see that the pen drive has been formatted with exFAT file system.

Format Successfully


When Windows File Explorer or Disk Management failed to format pen drive, it is not a bad choice to format pen drive using CMD. But if you want to format pen drive more simply and flexibly, it is recommended to pick up AOMEI Partition Assistant. It can not only format drive, but also make conversion between NTFS and FAT32 file system. And you get more advanced features like converting dynamic disk to basic without losing data, migrate OS from MBR to GPT and wipe system hard drive etc, if you upgrade it to Professional edition.