Command Prompt - Advanced Disk Management Commands

In one of our previous articles, we've shown how to manage your disks using the Disk Management utility. Now it's time to see how the same can be done from the Command Prompt using the DiskPart program. In this article you will learn how to create, format, delete and check your partitions for errors, directly from the Command Prompt.

NOTE: In order to perform any action presented in this article, you need to have administrative permissions and run the Command Prompt as administrator. Check out How to Run Programs as Administrator in Windows 7 to see how to run Command Prompt as administrator.

Important: If you misuse the commands listed in this article, you can risk losing your data. It is important to be careful and have a backup available for your data. Therefore proceed carefully and don't say we did not warn you. :)

Create a Partition From Command Prompt

First of all you have to type diskpart to access the program called Diskpart.

Command Prompt

After you've launched diskpart it's time to establish which hard-disk will be used to create a new partition. You need to select the hard disk using the select command. To view available disks and select the desired one you will use the commands list and select, as you can see below. First type list disk. This lists the available hard disks. To select the disk you desire, type select disk followed by the number of the hard disk you want to use.

Command Prompt

To create a new partition you need to use the create partition command followed by partition type and size.

The list command used previously also displays the available free space on each hard disk. Your partition must be of a size equal or less to the amount of available free space.

In order to make a new primary partition with the size of 5000 MB, let's say, we will type create partition primary size=5000. Use the same command and change the size according to your needs and the available free space on your hard disk.

Note: More info about partition types can be found in the article What Is A Partition?.

Command Prompt

Now you have the possibility to assign a letter to the newly created drive by using the assign command. We will assign the R letter by typing assign letter = R.

Command Prompt

Finally you have to format the newly created partition, in order to use it. Type the command format fs=ntfs quick. Use help format to find out more information about this command.

Command Prompt

When you are done working with diskpart, type the exit command to close the program.

Command Prompt

Delete a Partition From Command Prompt

When you need to delete a drive from your computer, the procedure is quite simple. First, open the diskpart application. Then, select the partition you want to delete and type the delete partition command. A sample of how the delete operation works in Command Prompt is provided below. It is a matter of selecting the disk where the partition is found, then selecting the volume to be deleted and running the deletion command.

Command Prompt

Check the State of a Disk

To check a disk for errors you have to use the chkdsk command. Just type chkdsk followed by the drive letter. I recommend that you always use this command in combination with the /f parameter. This enables the tool to automatically fix any errors it finds.

As an example, we will scan the h: drive for errors by typing chkdsk /f h: and pressing Enter. The scan process will start.

Command Prompt

After the scan is finished you will see a report similar to the one from the picture below.

Command Prompt

This summarizes how much disk space the partition has, how many files are in use by the system, how much free space is available on the disk, how many bad sectors were identified, etc.

Conclusion

Despite the fact that you might think it's hard to manage your partitions through Command Prompt, I hope I managed to prove that it's not that much of a deal. The procedures are not that complicated. If you have any questions, feel free to leave a comment.