How to Format a Hard Drive from the Command Prompt in Windows

Last update: 23/05/2025
Author Isaac

100TB-0 hard drives

Formatting a hard drive can seem like a complex task, especially when done outside of the usual Windows graphical tools . However, using the Command Prompt ( CMD ) to clean and prepare a storage drive is a simpler process than it appears and offers a much higher level of control compared to other methods . Knowing how to proceed can get you out of trouble with disk errors, operating system installation problems , or when you need to erase all traces of your data.

This article comprehensively compiles and synthesizes all the most up-to-date, clear, and practical knowledge on how to format hard drives and partitions using the Command Prompt in Windows . It covers all possible steps and variations, as well as recommendations and precautions to ensure the process is safe and effective, whatever your needs. Furthermore, we will delve into the available commands , formatting types, situations where formatting is useful, frequently asked questions, and simple alternatives for users with varying levels of experience.

Why format a hard drive from CMD?

The Windows Command Prompt (CMD) , along with tools like DiskPart , has become indispensable for advanced disk management tasks. While we usually resort to formatting when the computer stops working properly, there are other reasons why this procedure is essential :

  • Install or reinstall the operating system from scratch, prepared for a clean installation without previous errors.
  • Remove viruses, corrupted data, or sector errors that slow down the system or make it unstable.
  • Recover space and useful life on used disks or with problematic partitions.
  • Change the file system (for example, from FAT32 a NTFS or exFAT), especially relevant when you need compatibility between different operating systems.
  • Erase all data before selling, recycling, or transferring a device.
  • Fix unrecognized disk problems, unusable partitions or RAW drives.

Formatting a hard drive doesn't just mean deleting files; it leaves the drive ready to be used again, as if it were brand new . However, it's important to understand that all data will be erased , and it's crucial to make a backup beforehand whenever possible.

Preparations before formatting from CMD

Before you start formatting your hard drive from the Command Prompt, it's a good idea to take a few steps to minimize risks and avoid unpleasant surprises:

  • Make a backup of all important data. The process eliminates absolutely everything.
  • Have the drivers and necessary programs to reinstall the operating system and your applications if the disk you are going to format is the primary one.
  • Create a means of Boot (USB or DVD) with the operating system if you are going to format the main disk where Windows is.
  • Identify the disk and partition correctly that you are going to format. A selection error can be irreparable.
  • Keep your product keys and settings safe..

Following these basic steps will ensure that you can restore your PC after formatting and that the process is safe.

Main methods to format a hard drive from the Command Prompt

format cmd

There are several ways to format a hard drive using the command line in Windows. Two main methods stand out: using the `format` command or employing the powerful `DiskPart` utility . Each method has its own characteristics and is recommended depending on the situation.

The FORMAT command : This is the most direct method. It allows you to quickly format a specific partition using simple commands. Very useful if your goal is to clean a secondary drive, USB flash drive, SD card, or a specific partition.

  How to review file access and modifications in Windows 11

The DISKPART command is an advanced disk management tool that provides access to operations such as deleting, creating, and removing partitions, completely wiping a drive, and setting file systems (NTFS, exFAT, FAT32, etc.). It is ideal for deep formatting, error correction, complete disk cleanup, or when you need to create partitions from scratch.

Let's look in detail at how to use each of these methods.

How to open Command Prompt as administrator

To perform disk formatting and management tasks, you must run Command Prompt (CMD) with administrator privileges . This ensures you have the necessary authorization to modify the computer's storage.

  1. press the combination Win + WILL and type “cmd” in the Windows search bar.
  2. Right click on "Symbol of the system" and select "Execute as an administrator".
  3. If prompted, accept User Account Control to authorize the action.

Once inside the black CMD window, you can now enter the necessary commands.

Format disks and partitions using the FORMAT command

The `format` command is the traditional and straightforward way to format a drive or partition from the command line. It's especially useful if you already have the partition ready and only need to change the file system or wipe its contents.

  1. Identify the letter of the drive you want to format (for example, D:).
  2. In the CMD window, type the following command according to your needs:
    • For NTFS: format D: /fs:ntfs
    • For exFAT: format D: /fs:exfat
    • For FAT32: format D: /fs:fat32
  3. You can add the parameter /q at the end to do a “quick format” (faster but less deep).
  4. The system will ask for confirmation. Write S and press Enter to confirm.
  5. You can assign a label (name) to the unit if you wish.
  6. Wait for the process to complete; the time it takes depends on the size and type of drive.

Practical example:

format E: /fs:ntfs /q

This command quickly formats drive E: to NTFS.

Advantages of this method:

  • Ideal for cleaning pendrives, SD cards, external drives or secondary partitions.
  • It does not affect other partitions on the disk.
  • Simple and accessible.

Limitations: It's not recommended if you need to erase all partitions on a disk, repair serious errors, or clean boot disks. For those tasks, DiskPart is much better.

Formatting hard drives from CMD with DiskPart: the professional method

The DiskPart utility is an advanced tool built into Windows designed for low-level disk and partition management. With it, you can list, select, clean, create, and delete partitions, as well as format them with different file systems. This method is the safest and most comprehensive for:

  • Format internal hard drives or external from scratch.
  • Fix errors disk, leaving the unit as new.
  • Complete partition deletion and data.
  • Change the file system of an entire album.
  • Prepare disks for a new installation of Windows or another operating system.

Step by step to format a disk with DiskPart:

  1. Open the Command Prompt as administrator following the instructions above.
  2. Write diskpart and press Enter to run the tool.
  3. To see the connected disks, type list disk and hit Enter.
  4. Identify the number corresponding to the disk you are going to format (for example, 2).
  5. Select the disk with select disk 2 (replace 2 with your disk number).
  6. If you want to completely wipe the disk (erasing all partitions and data), run clean and confirm the action.
  7. Now, create a new primary partition with create partition primary.
  8. Select that partition with Select Partition 1 (or the corresponding number).
  9. You can set it as active with active (if this is the partition where you will install Windows).
  10. Format the partition to the desired file system:
    • format fs = ntfs for NTFS
    • format fs=exfat quick for exFAT (adds “quick” for fast formatting)
    • format fs = fat32 quick for FAT32
  11. Once completed, you can assign a drive letter with assign letter=X (choose the letter you prefer).
  12. Write exit to get out of Diskpart and the CMD window.
  This is an easy way to cut and paste songs from a Windows 10 PC.

IMPORTANT NOTE: The clean command deletes all data and partitions from the selected disk. There is no going back, so double-check the disk number before pressing Enter.

Practical example of formatting and complete preparation of a disk

Let's say you have an external or secondary drive that you want to restore to factory-fresh condition to install a new operating system or use for storage. The process would be:

  1. Open CMD as administrator and run diskpart.
  2. Usa list disk to view the discs. For example, you detect that yours is the disc 2.
  3. Select the disk with select disk 2.
  4. Write clean to erase all partitions and data.
  5. Initialize the disk, depending on the system type, with:
    • convert gpt for modern drives and new systems.
    • convert mbr for compatibility with older systems.
  6. Create a new partition: create partition primary.
  7. Select that partition: Select Partition 1.
  8. Format to the desired file system, for example format fs = ntfs quick.
  9. Assign a letter: assign letter=Z.
  10. Exit Diskpart with exit.

In a matter of minutes, the disk will be ready for use, with no trace of previous data and the correct file system.

Options and advanced syntax for formatting commands

The format and DiskPart commands offer various options to adapt the process to each specific need. Some of the most commonly used are:

  • /q: Quick format. Erases only the file table; it does not completely rewrite data.
  • /fs:: Specifies the file system (NTFS, FAT32, exFAT, UDF, etc.).
  • /v:: Allows you to assign a volume label to the drive.
  • /p:: Performs data overwrite passes for more secure erasure.
  • assign letter=X: Using DiskPart, allows you to choose the drive letter for the new volume.
  • convert gpt / mbr: Defines the partition type (GPT is standard on recent systems, MBR for legacy compatibility).

With these parameters, you can customize the process to achieve speed, security, or compatibility based on your needs.

Format disks to exFAT from Command Prompt

The exFAT file system is especially useful when you want compatibility between Windows, macOS, and other devices , such as cameras, game consoles, or media players. You can format a partition directly to exFAT using the following commands within DiskPart:

  1. Open CMD as administrator and type diskpart.
  2. Run list disk and select the target disk.
  3. Usa list partition to view the partitions and select the one you want to format.
  4. Introduce format fs=exfat quick for quick formatting to exFAT.

This method works for hard drives, SSDs, USB drives, or SD cards. If exFAT doesn't appear as an option, you may need to update Windows or try alternatives like EaseUS Partition Master, especially if the drive has a large capacity.

Format external drives, USB drives, and SD cards from CMD

The process for formatting external storage devices is almost identical to that for formatting an internal drive, except you must be extra careful to identify the correct drive to avoid losing data on the wrong drive. The general steps are:

  1. Connect the external device to the computer.
  2. Open Command Prompt as administrator.
  3. Starts diskpart.
  4. Use list disk to see all connected devices.
  5. Select the correct disk number (select diskX).
  6. List the volumes with list volume if you need to format a specific partition.
  7. Select the partition to format (select volume).
  8. Run the format command on the desired file system (format fs = ntfs quick, format fs = fat32 quick o format fs=exfat quick as appropriate).
  9. Exit the program with exit.
  Easy methods to Create Yahoo Electronic mail With out Telephone Quantity

Tip: If the device shows errors or does not allow access, you can first try performing a clean to erase all information and partitions.

Total cleaning options: "clean" and secure erase

For those cases where you want to ensure that not even the smallest piece of data can be recovered, DiskPart's clean command is your best ally. This command erases all partition information and the partition table, leaving the disk "uninitialized ," ready to start from scratch. For an even deeper clean, some third-party tools allow you to overwrite all sectors multiple times, such as EaseUS BitWiper , which simplifies the process for users without advanced experience.

Remember that once clean is executed , there is no easy way to recover the data except through professional recovery software, and even then, success is not guaranteed.

What are DiskPart commands and how do they work?

DiskPart is a command-line utility available from Windows XP onwards (including Windows 11 , 10, 8, 7, and Vista). It allows you to perform advanced operations on physical disks, partitions, and volumes. Key commands include:

  • list disk: Displays all connected disks.
  • select disk n: Select disk number n to work on.
  • clean: Erases all partitions and leaves the disk uninitialized.
  • convert gpt/mbr: Change the partition type.
  • create partition primary: Create a primary partition.
  • select partition n: Changes focus to the selected partition n.
  • format fs=type: Format the partition to the desired file system.
  • assign letter=X: Assign a drive letter to the partition.
  • Delete Partition: Deletes the selected partition.

The syntax is usually very straightforward, although it's essential to run each command on the correct disk. If you enter the wrong number, you could lose irrecoverable data. Be careful!

What happens to deleted data? Recovering after formatting

Once you complete the formatting process using CMD, all data on the formatted partition or disk will be immediately erased. Therefore, we strongly recommend that you make a backup if you have important files. If you accidentally format the disk for any reason, the following is recommended:

  • Do not write any new data to the drive.
  • Use specialized software such as Recovery o EaseUS DataRecovery as soon as possible to try to recover files.
  • Please note that recovery is not always possible, especially after a full format or clean command.

Prevention, in this sense, remains the best ally.