DiskPart commands: how to use, precautions and the main ones

Índice de conteúdos

DiskPart commands is a utility that comes with the Windows operating system and is used to manage partitions on disks, such as USB flash drives, SSDs, memory cards, external disks, etc.

Although it is a tool built into the computer, not everyone knows how to use it correctly or why it is so important.

That’s why we have put together a complete guide to DiskPart commands in this article. After checking it out, you will understand how to use it, what precautions are recommended with the utility and the main commands for everyday use.

Stay with us and find out the most important information on the subject!

Diskpart: como usar comandos em partições para formatar discos

What is a DiskPart?

DiskPart is a disk partitioning utility that uses command lines to perform operations.

The successor to fdisk, Diskpart is compatible with Windows and Windows Server, including XP and Server 2003 and more current versions such as Windows 7/8/10, Windows Server 2008/2008 R2/2012/2012 R2/2016.

DiskPart can be used to manage hard disk partitions, wipe and format USB flash drives, as well as allowing you to create, delete and merge (expand) partitions.

Basically, the DiskPart command line is similar to Disk Manager, but it is more powerful because it can implement some functions that Disk Manager cannot. For example, setting up mirrored volumes.

It can also be used after performing partition operations, eliminating the need to restart the computer. Diskpart runs in the command prompt interface.

On its website, Microsoft has outlined some important factors for using DiskPart and we have listed them below!

Determining the focus

In this case, the “focus” Microsoft is referring to is on the selected object – disk or volume. This means that, when using the tool, you can only focus on one of the selected objects.

It is also important to note that the focus is usually changed automatically, even without selection. A good example is when you create a new partition. Even without selecting it, the focus will be on the partition created last.


These are command lines directly linked to the parameters (which we will cover next). They are used to manage disk partitions.

In programming languages, syntax refers to the format in which sentences are written to define the form of the language.

For example, the syntax “clean [all]” is used when the intention is to clean or delete the data on a given disk.


In order for the commands to be executed by the interpreter, the parameters determine the value considered in the internal function.

Going back to the example we gave earlier, when we use the syntax “clean [all]”, the “all” is the value and means “all”. In other words: all disks can be cleaned and the data completely deleted.

On the Microsoft website, there is a list of all the commands that can be executed. It’s worth a look!

What care should I take with the tool?

If you are thinking of using Diskpart, remember that it is a utility that manipulates partitions and internal information on storage devices (internal and external disks, SSDs and USB flash drives).

For this reason, it is recommended that you use the Diskpart command lines with care, because once your command is executed, it cannot be undone.

This means that by using it, you risk completely destroying the files and folders stored on these drives.

So check your commands carefully before running them in Diskpart.

By the way, if you are thinking of using the tool to recover data or even entire partitions, consider leaving this recovery procedure in the hands of experts – like us at Bot.

That way, you can be sure that your data will be restored safely, without risking major damage or destroying your data for good.

How to use the tool?

You can use Diskpart if you have problems with your hard disk partitions that require repartitioning, need to format/create/resize a partition or partition your hard disk due to a Windows boot failure.

But, as with any operation involving important data, it is essential to make a backup before running the commands in Diskpart.

Remember: you need to run Diskpart in administrator mode.

To use Diskpart, the command prompt must be opened. This can be done in 2 ways:

  1. Typing “diskpart” in the “Search” box, right-clicking on Diskpart in the search results and selecting “Run as administrator”
  2. Pressing the “Windows” key and “R” simultaneously, then typing “diskpart” in the “Run” box.

With the command prompt open, you must first list the objects and then select a specific object to focus on.

When you focus on an object, all the Diskpart commands you write will act on that object.

How to use DiskPart in CMD?

CMD is nothing more than the Command Prompt. So, the procedure for using DiskPart is the same as above:

  • Search for “CMD” or “‘Command Prompt” in the Windows “Search” and run it as an administrator;
  • Click “Yes” when the “User account control” window appears;
  • Type the command “diskpart” and press “Enter”;
  • If you want to list the physical disks, just run the “list disk” command.

From there, you can proceed with the commands needed to perform the function you want, but be careful, as errors made in DiskPart can have a direct impact on the disks and the data they contain. The recommendation is not to mess with the utility if you are not familiar with it.

List of the main DiskPart commands

You can list the available objects using the list disk, list volume and list partition commands.

The list disk and list volume commands will display all the disks and volumes on the computer. However, the list partition command only displays the partitions on the disk you select first.

You can then select the destination using the select command, such as selecting the volume number (which should represent the specific number of the selected volume).

Remember: when you select an object, the focus remains on that object until you select a new, different object.

Some Diskpart commands can automatically change the focus. For example, when a new partition is created, the focus is automatically changed to the new partition.

Finally, don’t forget to press “Enter” after typing each command line in Diskpart.

Check out some of the main Diskpart commands below:

list disk/volume

  • Provides summary information about the disks/volumes available on your computer.

list partition

  • Displays information about each partition available on a specific disk.

select disk/partition/volume

  • Sets the focus on a specific disk/partition/volume.

detail disk/partition/volume

  • Provides detailed information about the currently selected disk/partition/volume.

create partition primary/logical

  • Creates a new primary/logical partition.

delete disk/partition/volume

  • Delete destination disk/partition/volume.

convert basic/dynamic/mbr/gpt

  • Creates a distribution volume on specified disks.


  • Assigns a drive letter or mount point to the selected volume.


  • Clears configuration data or all information from the disk.


  • Formats the volume or partition.


  • Marks the selected partition as active.

How do I format using DiskPart?

Formatting a disk or partition using DiskPart is simple, but it is essential that you are sure you need to do it. This is because, once the process is complete, you won’t be able to go back and your data will be permanently lost.

So if you need to, don’t hesitate to hire a specialist to format your disk correctly and safely.

That said, let’s go step by step:

  • First, follow all the steps we explained in the topic “How to use DiskPart in CMD?” up to the “list disk” step;
  • Identify the disk you want to format, type “select disk X” (instead of X, put the disk number) and press “Enter”;
  • Then type the command “Clean”, press “Enter” again and wait for the system to completely clean the disk;
  • Once complete, type the command “create partition primary” and press “Enter”;
  • Finally, you can format by typing “format fs=ntfs quick”, pressing “Enter” and waiting for the format to complete.

Important: “ntfs” is the format used for disks. So use the format indicated for your disk. For example: if it’s a USB flash drive, use the “FAT” format.

To finalize and assign a letter to the volume, just type the “assign” command, press “Enter” and you’re done! Formatting is complete.


As you can see, the Diskpart commands are useful for partitioning internal or external disks, but although they are not difficult to use, you need to be very careful not to make any mistakes.

So, if you are thinking of using Diskpart to fix a problem on your disk or recover data, consider a safer alternative: leaving your device in the hands of experts to ensure a proper restoration.

We at Bot Data Recovery are an experienced company and can help you recover your files safely, quickly and efficiently.

For your convenience, Bot offers free collection of the device at your address, or you can have it delivered in person to one of our receptions. From there, we analyze it, send you a quote and recover your data within 48 hours.

Recover your data with someone who understands the subject and has been in the professional recovery market for over a decade. Talk to our experts and get all your questions answered so that your data is safe and sound!


Posts relacionados