Software & toolsBest program to recover files on a diskBot Blog: data recovery and digital forensics
Written by the people who open the drives. Over 170 articles from our technical team.
Learn what DiskPart is, how to use it safely, which precautions to take and the main commands to manage disks and partitions in Windows.

DiskPart is a utility built into Windows that lets you manage the partitions on storage devices such as hard drives, SSDs, USB flash drives, memory cards and external drives.
Commands and programs are for logical errors; if important files are at risk, first see how hard drive recovery works in a lab.
Although it comes with every Windows computer, not everyone knows how to use it correctly or why it matters so much.
That’s why we have put together this complete guide to DiskPart commands. By the end, you will know how to use it, which precautions to take and which commands you are most likely to need.
Read on for the most important things you need to know!
DiskPart is a command-line disk partitioning utility.
The successor to fdisk, DiskPart works on Windows and Windows Server, from Windows XP and Windows Server 2003 onwards, including Windows 7, 8, 10 and 11 and Windows Server 2008 through 2022.
DiskPart can be used to manage hard drive partitions, to wipe and format USB flash drives, and to create, delete and extend partitions.
In short, DiskPart is the command-line counterpart of Disk Management, but it is more powerful because it can do things that Disk Management cannot, such as deleting protected recovery partitions or changing partition attributes.
Most changes made with DiskPart also take effect immediately, without restarting the computer. DiskPart runs in the Command Prompt.
On its website, Microsoft explains a few key concepts for using DiskPart, which we summarize below.
Here, “focus” means the object you have selected: a disk, partition or volume. Commands always act on the object that has the focus, and only one object can have it at a time.
Bear in mind that the focus can also change automatically, without you selecting anything. For example, when you create a new partition, the focus moves to that new partition.
Syntax is the way each command must be written, together with its parameters (which we cover next), to manage disks and partitions.
In programming languages, syntax is the set of rules that define how statements must be written.
For example, the syntax “clean [all]” is used to wipe the selected disk: it removes the partition table and the formatting information.
Parameters are the values you add to a command to tell the interpreter exactly what it should do.
Going back to the previous example, in “clean [all]” the parameter is “all”. Without it, clean removes the partition and volume information from the selected disk; with clean all, every sector of the disk is also overwritten with zeros, and the data is destroyed for good.
Microsoft’s website has a full list of DiskPart commands. It’s worth a look!
If you are planning to use DiskPart, remember that it changes the partitions and the internal structures of storage devices (internal and external hard drives, SSDs and USB flash drives).
That’s why you should use DiskPart commands with great care: once a command has run, there is no undo.
In other words, a single mistake can wipe out the files and folders stored on the drive.
So always double-check your commands, and the selected disk, before running them.
Also, DiskPart is not a recovery tool: every command writes to the disk. If you were thinking of using it to recover data or whole partitions, stop using the drive and leave the job to specialists like us at Bot.
That way, the recovery is carried out safely, without the risk of making the damage worse or losing your data for good.
DiskPart is useful when you need to repartition a disk, format, create or resize a partition, or fix the partitioning of a disk after a Windows boot failure.
But, as with any operation involving important data, you must back up your data before running any DiskPart command.
Remember: DiskPart has to run with administrator rights.
You can open DiskPart in two ways:
Once DiskPart is open, you first list the objects and then select the one you want to work on, which gives it the focus.
From then on, every DiskPart command you type acts on that object.
CMD is simply the Command Prompt, so the procedure is very similar:
diskpart and press Enter;list disk command.From there, you can run the commands you need, but be careful: mistakes in DiskPart affect the disks and the data on them directly. If you are not familiar with the utility, it is best not to use it.
You can list the available objects with the list disk, list volume and list partition commands.
list disk and list volume show all the disks and volumes on the computer, whereas list partition only shows the partitions on the disk you have selected.
You then select the object with the select command followed by its number, for example select volume 2 or select disk 1.
Remember: once you select an object, the focus stays on it until you select a different one.
Some DiskPart commands change the focus automatically. For example, when you create a new partition, the focus moves to that new partition.
Finally, don’t forget to press Enter after each command.
Here are some of the main DiskPart commands:
delete disk only removes a missing dynamic disk). Whatever is on a deleted partition or volume becomes inaccessible.clean all, it also overwrites every sector with zeros.Formatting a disk or partition with DiskPart is simple, but you must be absolutely sure you want to do it: once the process is complete, there is no going back and the data on it will be lost.
So, if the disk still holds data you need, don’t format it: talk to a data recovery specialist first.
With that in mind, here are the steps:
list disk command;select disk X (replace X with the disk number) and press Enter. Double-check it: selecting the wrong disk will erase it;clean, press Enter and wait for the disk to be wiped;create partition primary and press Enter;format fs=ntfs quick, pressing Enter and waiting for the format to finish.Important: NTFS is the usual file system for Windows hard drives. Choose the one that suits your device: for a USB flash drive, for example, use FAT32 (fs=fat32), or exFAT (fs=exfat) if you need to store files larger than 4 GB.
To finish, type assign to give the volume a drive letter and press Enter. That’s it: the drive is formatted!
Read next
As you have seen, DiskPart commands are useful for partitioning internal or external disks. They are not difficult to use, but you must be very careful not to make mistakes.
So, if you are thinking of using DiskPart to fix a problem with your disk or to recover data, consider a safer option: leave your device in the hands of specialists.
At Bot Data Recovery, we are an experienced team and can help you recover your files safely, quickly and efficiently.
For your convenience, Bot offers free collection of the device from your address (islands not included), or you can drop it off in person at one of our reception points in Lisbon, Coimbra, Porto and Braga. We then diagnose it free of charge and send you a quote, with a standard turnaround of up to 48 hours.
Trust your data to people who know what they are doing. Talk to our specialists and get all your questions answered before you put your data at risk.
Bot Blog
Has your device failed and are the files important?
The diagnosis finds the fault and tells you whether recovery is possible. You get the quote before any work starts.