sodcalculator

10 Tech How-To

How to Format Hard Drive from Command Prompt or Diskpart

Guide 10-42911 · Updated · Step by step

Formatting a hard drive from the Command Prompt or Diskpart gives you precise control over the process, especially when the usual graphical tools fail or when you need to clean a drive completely. This guide walks you through both methods, from opening the right tools to verifying the result, and covers the common pitfalls and fixes.

What You’ll Need

  • A Windows PC (Windows 10 or 11 recommended, but the steps work on Windows 7/8 too).
  • Administrator access. You must be able to run Command Prompt as administrator.
  • Backup of any data you want to keep. Formatting erases everything on the drive.
  • The drive letter or disk number of the drive you intend to format. You can find this in File Explorer (This PC) or Disk Management.
  • If you are formatting the system drive (where Windows is installed), you will need a Windows installation USB or recovery drive, because you cannot format the drive while Windows is running from it.

Step-by-Step

Method 1: Using the Format Command (Quick and Simple)

  1. Open Command Prompt as administrator. Press the Windows key, type cmd, right-click on “Command Prompt” and choose “Run as administrator”. Accept the UAC prompt.
  2. Identify the drive letter. In the Command Prompt, type wmic logicaldisk get deviceid, volumename, size and press Enter. Note the drive letter (e.g., D:) of the drive you want to format. Double-check you have the correct one.
  3. Run the format command. Type the following and press Enter:
    format D: /FS:NTFS /Q
    Replace D: with your drive letter. /FS:NTFS sets the file system to NTFS (use FAT32 or exFAT if needed). /Q performs a quick format. Omit /Q for a full format, which scans for bad sectors and takes much longer.
  4. Confirm the prompt. You will see a warning: “Insert new disk for drive D: and press ENTER when ready…” Press Enter.
  5. Enter a volume label (optional). Type a name for the drive (e.g., “Backup”) and press Enter, or just press Enter to leave it blank.
  6. Wait for completion. The command will show progress. When it finishes, you will see “Format complete.”

Method 2: Using Diskpart (More Control, Clean and Format)

  1. Open Command Prompt as administrator as described above.
  2. Launch Diskpart. Type diskpart and press Enter. You will see the DISKPART prompt.
  3. List the disks. Type list disk and press Enter. Note the disk number (e.g., Disk 1) of the drive you want to format. Be extremely careful: selecting the wrong disk can wipe your entire system.
  4. Select the disk. Type select disk 1 (replace 1 with the correct number) and press Enter. You should see “Disk 1 is now the selected disk.”
  5. Clean the disk (optional but recommended). Type clean and press Enter. This removes all partitions and data, making the disk completely unallocated. This is a full wipe and cannot be undone.
  6. Create a partition (if you cleaned). Type create partition primary and press Enter.
  7. Select the partition. Type select partition 1 and press Enter.
  8. Format the partition. Type format fs=ntfs quick and press Enter. Replace ntfs with fat32 or exfat as needed. Omit quick for a full format.
  9. Assign a drive letter. Type assign and press Enter. This gives the drive a letter so it appears in File Explorer.
  10. Exit Diskpart. Type exit and press Enter.

Common Mistakes

  • Choosing the wrong drive or disk. The most serious mistake. In Diskpart, using select disk with the wrong number will wipe that entire disk. Always verify the disk number and size before proceeding.
  • Formatting the system drive while Windows is running. Windows will not allow you to format the drive that contains the operating system. You must boot from a recovery drive or installation media.
  • Using the wrong file system. NTFS is best for Windows system drives and large files. FAT32 has a 4GB file size limit. exFAT is good for external drives used with other devices. Choose based on your needs.
  • Forgetting to back up. Formatting erases everything. There is no simple undo.
  • Interrupting the format. Closing the Command Prompt or unplugging the drive during a full format can leave the drive in an inconsistent state. Let it finish.

Tips

  • Use quick format when possible. A quick format only removes the file system structure, making the drive appear empty. It is much faster and sufficient for most cases. A full format is only needed if you suspect bad sectors or want to securely erase data (though it is not a secure erase).
  • Check the drive letter in File Explorer first. Open “This PC” and note the exact drive letter and its size to avoid mistakes.
  • For external drives, use exFAT. If you use the drive with both Windows and Mac or game consoles, exFAT is a good middle ground.
  • Use Diskpart’s list volume command. It shows all volumes with their drive letters and file systems, which is helpful for verification.
  • After formatting, check the drive health. Run chkdsk D: /f (replace D:) to check for errors, especially after a full format.

Troubleshooting

  • “Access is denied” error. You are not running Command Prompt as administrator. Right-click and select “Run as administrator”.
  • “The disk is write-protected.” This often happens with SD cards or USB drives that have a physical lock switch. Check the side of the device. If no switch, use diskpart and run attributes disk clear readonly after selecting the disk.
  • “Cannot format because the disk is in use.” Some program is using the drive. Close any open files or windows from that drive. If it still fails, try in Safe Mode or use Diskpart’s clean command first.
  • Format fails with “The volume is too big for FAT32.” FAT32 has a 2TB limit and a 4GB file size limit. Use NTFS or exFAT instead.
  • Diskpart says “Diskpart is unable to clean the disk.” This can happen if the disk is offline. In Diskpart, type select disk X, then online disk, and try clean again.
  • After formatting, the drive does not appear in File Explorer. You may have forgotten to assign a drive letter. In Diskpart, select the volume and type assign.

Frequently Asked Questions

Will formatting a hard drive permanently delete all data?

Formatting removes the file system and marks the space as available, but the actual data remains on the disk until overwritten. For sensitive data, use a tool that overwrites the drive with zeros or use Diskpart’s clean all (which takes much longer).

What is the difference between quick format and full format?

A quick format simply creates a new file system and removes the old one, taking seconds. A full format also scans the entire disk for bad sectors and writes zeros to every sector, which takes much longer and is more thorough.

Can I format the C: drive from Command Prompt?

No, not while Windows is running. You must boot from a Windows installation USB or recovery drive, open Command Prompt from the repair options, and then use Diskpart to format the system drive.

What file system should I choose?

For a Windows system drive, NTFS. For external drives used with multiple devices (like TVs or game consoles), exFAT. For very small drives (under 4GB) and compatibility with older devices, FAT32.

Is it safe to use Diskpart?

Yes, if you are careful. The danger is selecting the wrong disk. Always double-check the disk number and size before running clean or format. Once you wipe the wrong disk, the data is gone.

How long does a full format take?

It depends on the drive size and speed. A 1TB HDD can take several hours, while an SSD might take 30 minutes to an hour. A quick format takes less than a minute.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →