Table of Contents
1. Open Command Prompt as Administrator
2. Use Diskpart to Format the Drive
3. Verify the Result
When to Use Diskpart Over GUI
Home System Tutorial Windows Series How to use the diskpart command to format a drive in Windows

How to use the diskpart command to format a drive in Windows

Aug 05, 2025 pm 01:56 PM
diskpart 格式化驱动器

To format a drive using diskpart in Windows, open Command Prompt as Administrator by pressing Windows + X and selecting Command Prompt (Admin) or Windows Terminal (Admin), then click Yes if prompted by UAC; next, type diskpart to enter the tool, list disk to view all drives, select disk X replacing X with the correct disk number based on size, clean to erase all data and partitions, create partition primary to make a new partition, select partition 1 to choose it, format fs=ntfs quick or format fs=fat32 quick to format with the desired file system using quick format, assign to give the drive a letter, and finally exit to leave diskpart; verify the result by opening File Explorer to confirm the drive appears and is accessible. Always double-check the disk number before cleaning to avoid permanent data loss on the wrong drive. This method is ideal when the drive doesn’t appear in File Explorer, shows file system errors, fails to initialize, or has hidden partitions limiting its capacity.

How to use the diskpart command to format a drive in Windows

Formatting a drive using the diskpart command in Windows is a powerful method, especially when the standard GUI (File Explorer) fails—like with stubborn drives, incorrect file systems, or unallocated space. Here's how to do it properly and safely.

How to use the diskpart command to format a drive in Windows

1. Open Command Prompt as Administrator

Before using diskpart, you need elevated privileges.

  • Press Windows + X and choose Command Prompt (Admin) or Windows Terminal (Admin).
  • If prompted by UAC (User Account Control), click Yes.

? Always be cautious with diskpart—it can erase data permanently.

How to use the diskpart command to format a drive in Windows

2. Use Diskpart to Format the Drive

Follow these steps carefully:

  1. Type the following command and press Enter:

    How to use the diskpart command to format a drive in Windows
    diskpart
  2. List all disks to identify the correct one:

    list disk
  3. Identify your target drive by size. Once sure, select it (replace X with the actual disk number):

    select disk X
  4. Clean the disk (this deletes all partitions and data):

    clean
  5. Create a new primary partition:

    create partition primary
  6. Select the newly created partition:

    select partition 1
  7. Format the partition with a file system (e.g., NTFS or FAT32). For example:

    • For NTFS:
      format fs=ntfs quick
    • For FAT32:
      format fs=fat32 quick

    ? The quick flag skips a full scan—faster but less thorough. Remove it for a full format.

  8. Assign a drive letter:

    assign
  9. Exit diskpart:

    exit

3. Verify the Result

  • Open File Explorer—your drive should now appear with the assigned letter.
  • Check that it’s formatted correctly and accessible.

⚠️ Warning: Double-check the disk number before running clean. Formatting the wrong drive can result in permanent data loss.


When to Use Diskpart Over GUI

  • The drive doesn’t show up in File Explorer.
  • You’re getting errors like “The volume does not contain a recognized file system.”
  • You’re preparing a USB drive or SSD that’s not initializing properly.
  • You need to remove hidden partitions or restore full capacity.

Basically, diskpart gives you low-level control. Just proceed step by step, and make absolutely sure you’re selecting the right disk. Once done, your drive should be clean and ready to use.

The above is the detailed content of How to use the diskpart command to format a drive in Windows. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fix: Recovery environment not found in Windows 11/10 Fix: Recovery environment not found in Windows 11/10 Apr 28, 2023 pm 04:25 PM

The recovery environment is an integral part of Windows and is usually turned on when your PC encounters a problem. Now, what if your system fails to boot into the recovery environment and displays a "Recovery Environment Not Found" error message? This can be a very serious problem for you as you cannot even reset or repair your system. Fix 1 – Force boot the system into RE If you are unable to boot into the Windows Recovery Environment, you can force boot the system into it. 1. Shut down your computer. 2. After making sure that the device is completely turned off, tap the power button once to start the device. When you reach the manufacturer's logo screen, press and hold the power button again to completely shut down the device. 3. Repeat these force-boot-s again

5 Easy Ways to Format USB to NTFS Windows 11 5 Easy Ways to Format USB to NTFS Windows 11 Apr 13, 2023 pm 04:52 PM

USB drives are a great way to transfer data easily and efficiently. However, over time, your USB drive may lose its performance due to bad sectors or leftover data. If you have been facing performance issues with your USB drive, then formatting it can help you improve the same. NTFS is a widely supported format type in Windows and can help you transfer large amounts of data compared to FAT32. Here's how to format a USB drive to NTFS on Windows 11

How to find which disk is which in diskpart's 'list disk' command How to find which disk is which in diskpart's 'list disk' command Aug 21, 2025 am 02:07 AM

Usedisksizefromlistdiskoutputtomatchknowndrivecapacities,asDisk0(238GB)likelycorrespondstoa256GBSSD,Disk1(931GB)toa1TBHDD,andDisk2(14GB)toaUSBdrive.2.Cross-referencewithDiskManagement(diskmgmt.msc)toverifydiskhealth,partitionlayout,andvolumelabelsmat

How to fix a disk that is stuck in a 'Read-only' state with diskpart How to fix a disk that is stuck in a 'Read-only' state with diskpart Aug 06, 2025 am 04:15 AM

RunDiskPartasAdministratorbyopeningCommandPrompt(Admin)andtypingdiskpart.2.Identifytheaffecteddiskusinglistdisk,selectitwithselectdiskX,andcheckitsread-onlystatusviaattributesdisk.3.Cleartheread-onlyflagusingattributesdiskclearreadonlyandconfirmthech

How to use the diskpart command to format a drive in Windows How to use the diskpart command to format a drive in Windows Aug 05, 2025 pm 01:56 PM

ToformatadriveusingdiskpartinWindows,openCommandPromptasAdministratorbypressingWindows XandselectingCommandPrompt(Admin)orWindowsTerminal(Admin),thenclickYesifpromptedbyUAC;next,typediskparttoenterthetool,listdisktoviewalldrives,selectdiskXreplacingX

How to mount a VHD file as a drive letter using diskpart commands How to mount a VHD file as a drive letter using diskpart commands Aug 13, 2025 am 05:06 AM

OpenCommandPromptasAdministrator.2.Launchdiskpartbytypingdiskpart.3.SelecttheVHDfileusingselectvdiskfile="C:\Path\To\Your\disk.vhd".4.AttachtheVHDwithattachvdisk(orattachvdiskreadonlyforread-onlyaccess).5.Listvolumeswithlistvolume,selectthe

Automating diskpart commands with a script: [How to create a .txt script file] Automating diskpart commands with a script: [How to create a .txt script file] Aug 07, 2025 am 03:02 AM

To create and use diskpart scripts, you must first write the commands in a text editor and save them as .txt file, and then run diskpart/s execution through the command prompt with administrator permissions. 1. Create a script file: Enter the diskpart command in Notepad, one per line, such as selectdisk0, clean, createpartitionprimary, assignletter=C, formatfs=ntfsquick, exit; 2. Save the file: Save the file in UTF-8 encoded .txt format, such as C:\scripts\clean_drive.txt, pay attention to selecting the "All Files" type

Fixing 'The selected disk is not a fixed MBR disk' error in diskpart Fixing 'The selected disk is not a fixed MBR disk' error in diskpart Aug 13, 2025 am 02:12 AM

Theerror"TheselecteddiskisnotafixedMBRdisk"primarilyoccurswhenWindowsidentifiesthediskas"removable"insteadof"fixed,"regardlessofpartitionstyle.2.Tofixit,ensurethediskisconnectedinternallyviaSATAorNVMe,notthroughaUSBadapt

See all articles