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

Last update: 23/05/2025
Author Isaac

100TB-0 hard drives

Format A hard drive may seem like a complex task, especially when done outside of the usual graphical tools of Windows. However, using the Symbol of the system (CMD) to clean and prepare a unit storage It is a simpler process than it seems and offers a much higher level of control than other methods.. Knowing how to proceed can get you out of trouble with disk errors, installation problems, OS 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 Command Prompt in Windows, covering all possible steps and variations, as well as recommendations and precautions to ensure the process is safe and effective, whatever your needs. In addition, we will delve into the commands available, the types of formatting, the situations for which it is useful, frequently asked questions, and simple alternatives for users with different levels of experience.

Why format a hard drive from CMD?

El Windows Command Prompt (CMD), along with tools such as Diskpart, has become indispensable for advanced disk management tasks. Although 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 not only means erasing the files, but also leaves the drive ready to be used again, as if it were new.. Of course, it must be clear that all information is deleted and it is essential to make a Backup prior 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 of the most notable are: using the command format or use the powerful utility DiskpartEach method has its own particularities and is recommended according to the situation.

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 wipe a secondary drive, flash drive, SD card, or a specific partition.

  Complete guide to resizing partitions in Windows 11 without losing data

DISKPART command: This is an advanced disk management tool that provides access to operations such as deleting, creating, or deleting partitions, completely wiping a drive, or setting up file systems (NTFS, exFAT, FAT32, etc.). It's ideal for deep formatting, error correction, complete disk wipes, 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

In order to perform formatting and disk management tasks, it is essential Run Command Prompt (CMD) with administrator permissionsThis ensures you have permission to modify the device'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 command format It is the traditional and simple way to format a drive or partition from the command line. It is especially useful if you already have the partition ready and just need to change the file system or clean the 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 the 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

Utility Diskpart It's an advanced tool built into Windows designed for low-level disk and partition management. It lets you 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.
  How do I make games for my Instagram Stories? Game boards and derivatives

IMPORTANT NOTE: The clean command deletes all data and partitions from the selected disk. There's no going back, so double-check the disk number before hitting 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 commands format y Diskpart They allow for 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 file system exFAT It is especially useful when you want Compatibility between Windows, macOS, and other devices, such as cameras, 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.
  Solution to the error No audio output device

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

Total cleaning options: "clean" and secure erase

For those cases where you want to make sure that not even the smallest bit of data can be recovered, the command clean DiskPart is your best ally. This command removes all information from the partitions and the partition table, leaving the disk "uninitialized", ready to start from scratch. For an even deeper cleanup, 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 executed clean, there is no easy way to recover data except through professional recovery software, and even then, success is not guaranteed.

What are DiskPart commands and how do they work?

Diskpart It is a command line utility available from Windows XP onwards (including Windows 11, 10, 8, 7, and Vista). 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 from CMD, All data on the formatted partition or disk will be gone. immediately. Therefore, we insist that you make a backup if you have important files. If for any reason you accidentally format the disk, it is recommended to:

  • 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.