Diskpart command

Deepak Gupta
Deepak Gupta December 8, 2021
Updated 2021/12/08 at 5:46 AM

I’m certainly not the only one who has been touched with annoying devices. One of those that show you “read-only permission” or that you can’t even see on the computer. If we know a little computer science, we use the odd application to solve the problem, but in many cases this solution does not work and we must go a little further in search of solutions. If you want to find out more about this topic, I recommend this article to learn a way to fix your hard disk or memory in a different way, using the diskpart command

What is the diskpart command?

Diskpart is a utility available in Windows to manage all our storage devices, whether external or internal. It allows us to repair, clean, unlock or prepare units for proper operation on our PC.

It is true that there are many applications that perform these functions and that with a simple click on a graphical interface we can make everything easier. The fact is that many times these programs do not have the access or the necessary mechanisms to carry out the tasks assigned to a device. This is why we must go to low-level programs such as the diskpart command.

How do we access?

Only one requirement is necessary to run this powerful tool and that is that the user belongs to the group of team administrators.

Using the system search engine

In Windows 7 or later we just have to write its name in the search bar in the start menu.

Access diskpart through the search engine

By key combination

It is the easiest way to open it. We simply press the key combination Windows + R and we open the command execute and there we write diskpart.

Access the diskpart command to execute
Access diskpart by running

Diskpart command parameters

Despite its simplicity, it is a powerful tool that includes the necessary help for those who want to learn how it works. With the commands disk or help 39 commands that we can use are displayed, as well as a brief description of their functionality. Among the most used by users are:

List: shows a list with basic disk information (disk), partitions (partition), volumes (volume) or virtual disks (vdisk) that we have on our computer.

Select: This command is used in most operations since it allows us to select it listed with the previous command.

Assign: allows us to assign a drive letter to the volume that we have previously selected. If the drive letter is not specified, an available one will be assigned.

Create: Using this option we can create partitions or volumes on any hard drive. The structure for creating a partition is create partition [atributo] size. Being [atributo] any of the following options: efi, msr, extended, primary, or logical.

Break: It is used to divide a hard disk volume in two. We just have to write break disk = disk number in the diskpart.

Automount: When connecting a USB device or a hard drive to our PC, Windows assigns a drive letter from those available and installs the files necessary for its operation. With this command we have the possibility to enable or disable this automatic mounting of any basic or dynamic disk.

Delete: It allows us to eliminate any partition or volume from a disk. Be very careful when using this command as all stored information will be deleted.

Detail: displays the information of the selected disk, partition, volume, or virtual disk. Among the references we can find the disk id, brand, status, if it is read-only, if it is a boot disk, etc.

Clean: very powerful command that will eliminate all the formats of the selected disk or partition.

Format: With this command we can format a disk for use with Windows. Its structure varies depending on what you want and the type of disk you want to format. The most used arguments are:

Format fs="tipo" label= "etiqueta" unit=N quick compress override nowait 
fs= especificamos el formato NTFS, FAT ó FAT32
unit invalida el tamaño de la unidad de asignación predeterminada 
label= nombre de la etiqueta
quick es para ejecutar un formato rápido
compress los archivos creados en el volumen se comprimen predeterminadamente. Solo se usa para formatos NTFS 
override se utiliza para desmontar el disco en caso que otro programa lo esté utilizando
nowait hace que el comando devuelva constantemente el proceso de formato. Si no se especifica solo será visible el porcentaje.

It seems very complicated to understand, but it is not. Each argument is separated from the other by a space and it is not necessary to put them all for their correct operation. Later in the article we will see an example of how it works.

Shrink: It is used to reduce the space of the selected disk or partition. At the end of the process, an available space is created for the creation of a new partition.

Shrink desired=X mínimum=Y
X: cantidad de espacio en megabyte (MB) que se desea reducir el volumen. En caso que no se use este argumento el tamaño de reducción será el espacio disponible que posea la partición.
Y: especifica la cantidad mínima de espacio (en MB) en que se debe reducir el tamaño del volumen.

Examples of using the diskpart command

To see a real example of the use of these commands, we are going to repair a USB memory that cannot be accessed from the graphical interface.

List discs

The list command is always accompanied by the objective of our search. In this case we want to list all the disks on our PC. Don’t worry if you misspell a name or don’t remember how to type it, this powerful tool will make suggestions of what you can list and the correct way to write it.

list disks using diskpart command
list disks

Select disk

After viewing all the available disks, we will select the memory that we want to repair. Keep in mind that the number you must put is the one that appears in the table after Disk. That is why it is important to check the storage space of the USB memory well so as not to confuse it.

select disk
select disk

One step that at least I always do to avoid making mistakes is to re-list the available disks to make sure that the selected disk is the desired one. This step is very important because when we make a mistake with the selection of discs we can lose all the information of any other device.

selected disk
selected disk

Remove read-only permission

In this step we are going to eliminate the read-only permission of the device in case when trying to format we get an error.

remove read permission from device
remove read permission from device

Clear memory

With this simple command we erase the entire memory partition format.

clear memory format
clear memory format

Create partition

Having used the command clean We must create a partition to be able to format it.

create primary partition
create primary partition

Assign a drive letter

In this step we will assign a letter to our memory and we can do it in 2 ways. Letting the system choose from the available letters or as in this example assigning it ourselves.

assign a drive letter
assign a drive letter

Format it

The memory is now ready to be formatted. In this case, being a 16 GB memory and we will use the FAT32 file system

format memory
format memory

Once the process is finished, your memory is ready to continue using it.


You already have one more tool within Windows to repair your disks without the need to install third-party programs. So dust off those broken drives or memories you have in the drawer and try this example. In addition to inquiring about all the commands to expand the knowledge about this powerful tool.

Share this Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *