Windows DISKPART: commands, command prompt, clean

Windows DISKPART: commands, command prompt, clean

DISKPART can be used to overcome the limitations of the Disk management tool. It offers several commands to manage your disks and in this article we shall discuss about the most popular ones. This article will explain all you need to know about the DISKPART Command.

What is the DISKPART command? 

Diskpart is a command line tool which allows you to manage disks, as such some commands can only be accessed via diskpart and not by the disk management tool of Windows. The use of this tool involves a lot of caution!

DISKPART can be useful in such situations:

  • Access to disks that no longer appear in the disk management tool.
  • Convert a basic disk to a dynamic disk.
  • Create partitions.
  • The clean command allows you to delete all information stored on the disk.
  • Manage the partitions (create, delete, edit).
  • Assign, edit and delete a drive letter.
  • Format a partition (several options available).

How to use Diskpart?

  • Script
  • CMD (command prompt)

Using Diskpart via a script

  • Click on Start > Run.
  • Type cmd and press Enter.
  • The command prompt shall open.

From there we will simply indicate where diskpart will find the file containing the commands.

  • Move to the folder containing the files using the
    cd 

    command.

  • In our case we will use the example.txt file.
    • diskpart.exe /s exemple.txt
  • The example.txt file will contain the commands. In our example we will list the details of disk 1:
list disk
select disk 1
detail disk

Using DISKPART via the command prompt

  • Click on Start > Run.
  • Type cmd and press Enter.
  • Once the command prompt is open
  • Type:
    DISKPART

You have now accessed the diskpart tool.

How to list the disks?

  • You can list the disks, partitions or volumes.
  • You can use both the disk management tool of Windows and the diskpart tool, by positioning both of the windows side by side.

Selecting a specific disk

  • Type the following command:
    select disk n
  • Replace n with the disk number of your choice.

Getting info about a disk

For more information use the detail disk command. To get information about a specific disk, first you need to select it and the use the detail disk command. Example using the disk 2 :

list disk
select disk 2
detail disk

Selecting a partition

First you need to select the disk:

list disk
select disk n

Then use the below command to select the partition of your choice:

select partition n

Replace n with the partition number To get additional information about a partition:

list partition
select partition n
detail partition

How to select a volume?

First you must select your disk:

list disk
select disk n

List the volumes present using the below command:

list volume

To select a specific volume:

select volume n 

Where n is the the volume number To get information about the selected volume, type:

detail volume

Additional commands

The Help command

The help command will give you access to all the diskpart commands:

help <command> 

Example :

help clean

The Clean command - clear all information

  • The CLEAN command deletes all partitions, the configuration information and all the information stored on the disk.
  • The CLEAN ALL command deletes all partitions on the selected disk and permanently deletes the information stored on the disk.

Example of use (disk 1):

list disk
select disk 1
clean

The ASSIGN command - manage partitions letters

The Remove letter command:

list volume
select volume n
remove letter =N

To assign a new letter to a partition:

assign letter =N

The Format command: format a partition

Format the active partition or volume. 

Any more hard drive questions? Check out our forum!

Storage