How to clean and repair drive with DiskPart on Windows 11

If the drive is acting up or slowing down the computer, it could be a data corruption problem, which is when DiskPart can help.

Windows 11 DiskPart repair drive
Windows 11 DiskPart repair drive / Image: Mauro Huculak
  • To use DiskPart to repair a drive on Windows 11, open “Command Prompt” (admin), run the “DiskPart” tool, select and clean the drive, create an active primary partition, format the storage, and assign a drive letter.

On Windows 11, you can use the Check Disk (chkdsk) tool to scan and repair logical errors on a drive, but if the Task Manager continues to show one hundred percent active time on a drive, you’re still unable to access it, or you notice other problems, it could be a data corruption problem which you can resolve with DiskPart.

DiskPart is a command-line tool for managing drives on your computer. Usually, you would use the tool to set up a storage device, but if you’re having problems, you can use it to clean and repair the drive. Of course, this assumes you are dealing with a logical problem, not a hardware issue.

In this guide, I will teach you the steps to use DiskPart to revive a secondary hard drive on Windows 11.

Important: The instructions outlined below will delete any data on the drive. It’s assumed you have previously created a backup of the data you may need again.

Clean and repair drive with DiskPart on Windows 11

To erase and repair a hard drive on Windows 11 with DiskPart, use these steps:

  1. Open Start on Windows 11.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. Type the following command to open Diskpart and press Enter:

    diskpart
  4. Type the following command to determine the drive to format and press Enter:

    list disk
  5. Type the following command to select the storage and press Enter:

    select disk 3

    In the command, replace “3” with the flash drive number you want to use.

  6. Type the following commands to delete everything from the hard drive and press Enter:

    clean

    DiskPart clean drive

  7. Type the following command to create a primary partition and press Enter:

    create partition primary
  8. Type the following command to select the new partition and press Enter:

    select partition 1
  9. Type the following command to make the selected partition active and press Enter:

    active

    DiskPart create active partition

  10. Type the following command to format and make the hard drive bootable and press Enter:

    format FS=NTFS quick

    DiskPart format drive

  11. Type the following command to assign a drive letter and make the drive accessible and press Enter:

    assign letter=X

    In the command, change “X” for any available letter you want to use.

  12. Type the following command to quit the tool and press Enter:

    exit

Once you complete the steps, the drive will be erased, formatted, and mounted with the specified drive letter, fixing the errors you may have experienced in the past.

These instructions are suited for repairing secondary drives, such as a second drive you may have installed to store data, or external drives and even flash drives. If the drive with the problem is the drive where the operating system is installed, then you can use the Check Disk tool or the DISM and SFC tools. In the case that the installation continues with issues, Windows 11 includes a feature to reinstall the operating system, keeping your files, settings, and apps.

Update August 12, 2024: This guide has been updated to ensure accuracy and reflect changes to the process.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 15 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 21 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].