Manage Hard disk with command line tools. Disk Partition Utility (Diskpart) is a command-line tool for managing hard disk in Windows operating system. Diskpart has replaced with fdisk command-line tool which work with MS-DOS based operating system.
Diskpart can be used on both command prompt and PowerShell. But, you must well understanding what you are doing when using Diskpart. It happened too many time for students which formatted the entire disk with one command. The last one was a Lap top with lots of memorial photos and videos. Fortunately we had recovered all data successfully. But takes too much time.
To run the diskpart, press Windows+R button to open the Windows Run and type diskpart then press enter.
How to Create, Format a disk partition?
You may want to list installed hard disks of the system. Simply type ‘list disk’ then press enter.
So, in this PC we have tow hard disks. You must select the exact disk that you want to work with.
To select disk 1, just type ‘select disk 1’ and press enter, then type ‘list disk’ to see whether the disk has selected or not.
Now clean the disk by ‘Clean’ command and create a partition with create partition command. ‘Create partition primary size=40000’ this command will create a 40 GB primary partition from disk 1.
To check the created partition type ‘List vol’ command. The command will list all volumes.
The Volume 3 is the newly created partition. It is selected and ready to format it.
Type ‘format fs=ntfs quick’ to format the partition, and type ‘list vol’ to see the formatted partition with NTFS file system.
Now you have learned creating, formatting and some diskpart commands.
How to Delete a Partition or Volume.
To delete a partition or volume, first select volume then type delete partition. Like below screenshot.
See, the partition ‘Volume 3’ has deleted successfully.
How to Extend a Partition?
Extend is to add some more space to existing partition from the free space of a hard disk. To do this, simply follow the screenshot.
The ‘Extend size=10000’ will add 10 GB to the Volume 3 partition. If you don’t mention the size, the system will add all free space.
How to Shrink a Partition?
Shrink a volume is to create unallocated space from free spaces of an existing partition.
The diskpart has shrunk 19 GB from the Volume 3 successfully.
although diskpart or disk management can help you manage partitions, both of them have limitations such as you can only extend partition when there is unallocated space contiguous behind to the partition you plan to extend, or the extend volume will gray out. I have been troubled by this problem, but i found third-party software that allows you avoid the problem.
for more information: