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.

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 commands that you will mostly require.

List all DiskPart Commands
ACTIVE – Mark the selected partition as active.
ADD – Add a mirror to a simple volume.
ASSIGN – Assign a drive letter or mount point to the selected volume.
ATTRIBUTES – Manipulate volume or disk attributes.*
ATTACH – Attaches a virtual disk file.*
AUTOMOUNT – Enable and disable automatic mounting of basic volumes.*
BREAK – Break a mirror set.
CLEAN – Clear the configuration information, or all information, off the disk.
COMPACT – Attempts to reduce the physical size of the file.*
CONVERT – Convert between different disk formats.
CREATE – Create a volume, partition or virtual disk. (No virtual disk management in Windows XP.)
DELETE – Delete an object.
DETAIL – Provide details about an object.
DETACH – Detaches a virtual disk file.*
EXIT – Exit DiskPart.
EXTEND – Extend a volume.
EXPAND – Expands the maximum size available on a virtual disk.*
FILESYSTEMS – Display current and supported file systems on the volume.*
FORMAT – Format the volume or partition.*
GPT – Assign attributes to the selected GPT partition.*
HELP – Display a list of commands.
IMPORT – Import a disk group.
INACTIVE – Mark the selected partition as inactive.
LIST – Display a list of objects.
MERGE – Merges a child disk with its parents.*
ONLINE – Online an object that is currently marked as offline.
OFFLINE – Offline an object that is currently marked as online.
RECOVER – Refreshes 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.*
REM – Does nothing. This is used to comment scripts.
REMOVE – Remove a drive letter or mount point assignment.
REPAIR – Repair a RAID-5 volume with a failed member.
RESCAN – Rescan the computer looking for disks and volumes.
RETAIN – Place a retained partition under a simple volume.
SAN – Display or set the SAN policy for the currently booted OS.*
SELECT – Shift the focus to an object.
SETID – Change the partition type.*
SHRINK – Reduce the size of the selected volume.*
UNIQUEID – Displays 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