DiskPart Commands: Guide to Format and Fix Drives Not Working

Sometimes the disk on your Windows 10 system may not work correctly, or the Windows fails to start because of the hard disk error. To rectify such disk errors, Windows 10 comes with an excellent tool known as DiskPart.

The DiskPart is a powerful command tool that lets you manage the Windows disks and partitions using Command Prompt or Windows PowerShell. This command interpreter allows you to delete, create, and modify partitions on any drives your PC can detect, even the external hard drives and USB storage. It is quite useful when any Pendrive or hard disks get corrupted because of logical errors and stopped working. Using DiskPart commands, you can wipe out the data and start clean.

To fix various Windows 10/11 problems, we recommend Outbyte PC Repair:
This software will repair common computer errors, protect you from file loss, malware damage, hardware failure, and optimise your computer for peak performance. In three simple steps, you can resolve PC issues and remove virus damage:

  1. Download Outbyte PC Repair Software
  2. Click Start Scan to detect Windows 10/11 issues that may be causing PC issues.
  3. Click Repair All to fix issues with your computer's security and performance.
    This month, Outbyte has been downloaded by 23,167 readers.

DiskPart is not a new concept. It has been the part of the Windows even before Windows 10. It is the best alternative when other disk utility such as Disk Management Tool fails to work.

In this guide, we would learn to use the common DiskPart commands to fix ‘Drive not Working’ and other disk errors.

  7 Tools to Speed SSD and Hard Disk Drives

How to open DiskPart on Windows 10?

Launching the DiskPart is not a big task. You just require to open the command terminals, either the Command Prompt or Windows PowerShell with the administrative rights. 

In this guide, we would use the Command Prompt to run the DiskPart commands. The same commands can be directly used in Windows PowerShell without any changes.

  1. Search Command Prompt in the Windows search bar and launch it with admin rights.
    Open Command Prompt as Admin

  2. In the command window, type diskpart and hit enter. The DISKPART tool would be open and ready to use.
    launch DISKPART

  3. If you want to glance on the full list of available commands of DiskPart type help in the command window and press the enter key.
    diskpart help command

  4. After using it, type Exit and hit the enter key to exit the tool.Exit DiskPart

Common DiskPart Commands

We would now explore the common DiskPart Command Prompt commands that you will mostly require.

Command Description
ACTIVEMark the selected partition as active.
ADDAdd a mirror to a simple volume.
ASSIGNAssign a drive letter or mount point to the selected volume.
ATTRIBUTESManipulate volume or disk attributes.
ATTACHAttaches a virtual disk file.
AUTOMOUNTEnable and disable automatic mounting of basic volumes.
BREAKBreak a mirror set.
CLEANClear the configuration information, or all information, off the disk.
COMPACTAttempts to reduce the physical size of the file.
CONVERTConvert between different disk formats.
CREATECreate a volume, partition, or virtual disk. (No virtual disk management in Windows XP.)
DELETEDelete an object.
DETAILProvide details about an object.
DETACHDetaches a virtual disk file.
EXITExit DiskPart.
EXTENDExtend a volume.
EXPANDExpands the maximum size available on a virtual disk
FILESYSTEMSDisplay current and supported file systems on the volume.
FORMATFormat the volume or partition.
GPTAssign attributes to the selected GPT partition.
HELPDisplay a list of commands.
IMPORTImport a disk group.
INACTIVEMark the selected partition as inactive.
LISTDisplay a list of objects.
MERGEMerges a child disk with its parents.
ONLINEOnline an object that is currently marked as offline.
OFFLINEOffline an object that is currently marked as online.
RECOVERRefreshes the state of all disks in the selected pack. Attempts recovery on disks in the invalid pack, and resynchronizes mirrored volumes and RAID5 volumes that have stale plex or parity data
REMDoes nothing. This is used to comment scripts.
REMOVERemove a drive letter or mount point assignment.
REPAIRRepair a RAID-5 volume with a failed member.
RESCANRescan the computer looking for disks and volumes.
RETAINPlace a retained partition under a simple volume.
SANDisplay or set the SAN policy for the currently booted OS.
SELECTShift the focus to an object.
SETIDChange the partition type.
SHRINKReduce the size of the selected volume.
UNIQUEIDDisplays or sets the GUID partition table (GPT) identifier or master boot record (MBR) signature of a disk.

Listing Existing Hard Drives, Volumes & Partitions using DiskPart

Before applying any destructive commands, you can first check the current internal and external hard disks and USB storage layout.

To check the available disks:

  1. Open the DiskPart and after “DISKPART>” prompt type list disk and hit enter. This command will list all the available and detectable storage disks, including internal and external drives and USB storage.Diskpart list disk command
  2. To apply the DiskPart commands on the disks, you need to remember the disk number. For example, the windows disk is “Disk 0.

To display the list of detected Volumes:

  1. Launch DiskPart and next to “DISKPART>” prompt type list volume.diskpart list volume command
  2. All volumes would be listed.

Check the list of partitions:

  1. To check the partition list, you must first select the hard disk with the list disk command.
  2. After the disk list is displayed, type select disk followed by the disk number.diskpart select disk command
  3. Once the disk is selected, type list partition, and hit the enter key, the selected disk’s partition list will be displayed. You can further modify the partitions using the partition number.Diskpart list partition command

How to Delete Hard Drive, Volume, and Partition using DiskPart ?

If you want to delete the Volume or Partition of your system’s hard disk using Diskpart, follow these steps:

  1. First, select the hard drive using the select disk command, followed by the disk number.
  2. Now open the partition list of the chosen disk using list partition command.
  3. Chose the partition using select partition # command, replace with the required partition number.
  4. Once the partition is selected, you can delete it using the delete partition command. The partition will be deleted.Select and Delete the Partition using DiskPart
  5. Similarly, you can delete the disk volume. Type list volume, check your chosen volume number, then type select volume #, replacing # with your volume number.Delete volume using DiskPart
  6. Type delete volume, to delete the chosen volume.
  How to Clone Drives in Windows 10

How to Completely Wipe Out the Hard Disk using DiskPart?

If you face a problem in formatting the system hard disk, external hard drive, or the USB Pendrive, then using DiskPart, you can easily wipe them out. Obviously, you won’t be able to clean the disk on which your OS is installed.

  1. Similar to previous steps, on the DISKPART prompt window, type list disk.
  2. By typing select disk # command where is your disk number, choose the disk that you want to format completely.
  3. After selecting the disk, type clean command to format it completely. Remember that it would not warn you, so make sure that you have selected the correct disk.Clean disk using DiskPart
  4. After the cleanup, DiskPart would display the success message, and the disk would be ready for creating the new partitions. 
  10 Ways to Find What is Taking up Space on Hard Drive

How to Create and Format New Hard Drive Partitions using DiskPart?

Using the steps from the last section, you might have cleaned your hard disk. Now its time to create the new partitions and format them with Windows-friendly file systems like NTFS or FAT32.

create a new partition using diskpart
  1. Open the disk list using the list disk command and select the disk using the select disk # command, where # is the disk number.
  2.  After selecting the disk type the create partition primary command to create a partition using the entire space on that drive.
  3. If you want to create multiple partitions, you can assign how much space a partition could take. For that type, create partition primary size=X, where X is the size that you wish to set to the partition.
  4. To ensure that the new partition is listed, type list partition command.
  5. Use active command to activate the partition. It is required to use the partition as a bootable drive.
  6. To format the partition with the NTFS file system, use format FS=NTFS label=Data quick command. You can replace Data with any label you want.
  7. After it gets format, the DiskPart would automatically assign the letter to the partition. If it doesn’t, you can manually set it. For that type, assign letter=g, where you can replace g with any drive letter that you want. 
Format the partition and assign letter to it using diskpart

Conclusion

These are the top used DiskPart commands that you can use to fix your hard drive problems and clean the USB drives and hard disks.

There are more commands, too, if you want to know about them, type help after launching DISKPART in the command window.

1. How to open DiskPart in Windows 10?

You can open DiskPart utility through Command Prompt or Windows PowerShell in Windows 10. After launching any of the command terminals, type diskpart to launch DiskPart.

2. How to fix hard drive problems with DiskPart?

DiskPart utility is specifically available for solving the disk issues on Windows 10. After launching the diskpart, type the help command to know about all the commands supported by diskpart. This post guides you on how to use the most common DiskPart commands.

  How to Fix 100% Disk Usage in Windows 10

Leave a Comment