DiskPart is essentially the command-line equivalent to the Disk Management tool and can be useful in certain situations (such as when Windows won’t start). Be warned though, Diskpart is a powerful tool and unlike the Disk Management tool, it enables explicit control of partitions and volumes.
You’ll need to run DiskPart in administrator mode; one way to do this is to open your Start menu, type diskpart in the Search box, and then when diskpart.exe appears in the search results, right-click it and select Run as administrator.
Extend Volume using DiskPart
Once it’s running, type help at any time to see a list of commands. To get started, here’s how to extend a volume using DiskPart.
1. At the DISKPART> prompt, type: list disk to display all the drives on your computer. Each drive will have a disk number, starting with 0 (zero).
The result above tells us that I have two physical disks installed.
2. Unless you have only one drive, you’ll have to tell DiskPart which drive to use, like this: select disk n where n represents the number of the disk to modify.
5. Now that you’ve selected the partition to expand, go ahead and issue this command: extend to extend the volume. The extend command takes no options and displays no warning message or confirmation. The process begins immediately after you press the Enter key, and should take only a few seconds. The extend command will cause the current in-focus volume to be extended into contiguous unallocated space.
6. When it’s done, type exit to quit the DiskPart utility.
Clean and Format a USB Drive
Another good use for DiskPart is to clean and format a USB drive that is corrupt or not working properly. If you have tried to use the Format utility in Windows, but it’s not working, you can try to use DiskPart to fix the problem.
Here we will clean the USB drive, create a new partition, format it and assign a drive letter to it.
list disk select disk n clean list disk (You'll see an asterisk next to the disk name) create partition primary select partition 1 active format FS=NTFS label=Data quick (You can change Data to whatever name you want) assign letter = x exit
I’ve also written several articles that use the diskpart command:
DiskPart is a great command line utility for administrators and techies. You can format, resize, extend and manage your drives and volumes using this powerful tool. Enjoy!