Manage Your Disks in Windows with DiskPart
The Disk Management utility in Windows – a GUI based application – lets you perform various disk operations – such as setting active partitions; changing drive letters and paths; extending, shrinking, and deleting a volume; and formatting the drives. But the Disk Management utility is quite faulty and prone to errors. Typical problems that users face include random graying out, and disabling of the Extend Volume/ Shrink Volume tabs.
In this regard, the DiskPart utility is an excellent alternative to the inbuilt Disk Management application in Windows. The DiskPart utility is a text input command line application founded on scripts that let you create, erase and adjust the size of the different volumes on your hard drive. It is compatible with almost all the recent Windows versions – although in the XP, and the previous editions, you have to install the application manually (the DiskPart.exe installer does not work in them).
DiskPart, being a command prompt application, will require you to familiarize yourself with the different commands of the program. To get the various options/syntax for any command you can always type in Help [command] and press Enter.
Here is a list of simple operations of DiskPart to help you get started with the program.
- Starting/Running DiskPart
To start the DiskPart interface, go to the Start Search field in Vista, or the Run box in the case of XP/2000/2003, and enter DiskPart.exe. A command line for the program is launched. - Listing all the disks on the PC
To view all the hard disks installed in the system, enter list disk at the prompt. - Selecting a target disk
In order to choose a disk you plan on working with, use the command:select disk <disk number (###)>
Disk number can be obtained by using “list disk” above.
- Creating a partition
A partition (on an empty hard disk, or on some unallocated free space) is created with the command:create partition <partition type> [size=<n>] [offset=<n>] [id={<byte> | <guid>}] [align=<n>] [noerr]
The supported partition types are primary, extended, logical drive, EFI and MSR. (You can get more information on these with the Help command).
For instance:
create partition primary size=2000
will generate one primary partition of 2GB size. - Creating a volume
DiskPart lets you create RAID volumes with three (or even more) specified disks; and a simple/striped volume with any number of specified disks greater than two. The command for this is:create volume <volume type> [size=<n>] disk=<n>,<N>,<n>[,<n>[,…]] [align=<n>] [noerr]
For instance:
create volume raid size=1000 disk=A,B,C
will create an RAID-5 volume of 1 GB using disks A, B and C. - 6. Listing all volumes
The following instruction lists all the volumes so that you can check the number linked with the particular volume you wish to work on:list volume
- Selecting a volume
The following instruction selects a volume for performing operations on it:select volume <number>
The volume number is recovered using the “list volume” command above.
- Listing all partitions
The following instruction lists all the partitions so that you can check the number linked with the particular partition:list partition
- Selecting a partition
The following instruction selects a partition for performing operations on it:select partition <number>
The partition number is recovered using “list partition”.
.
10. Shrinking a volume
Shrinking of a particular volume can be achieved by the following instruction:
shrink [desired=<n>] [minimum=<N>] [nowait] [noerr]
For instance:
shrink desired=350 minimum=100
will shrink the current volume by 350MB, and 100 MB is the minimum space to be released if this is not possible.
There is another command that lets you find the maximum space by which you can reduce the size of a volume, which is:
shrink querymax [noerr]
11. Extending a volume/partition (increasing size)
To extend a particular volume/partition into unallocated and free space, use:
extend [size=<n>] [disk=<n>] [noerr]
For instance:
extend size=750
will take the current partition/volume and increase its size by a margin of 750MB.
12. Deleting a particular partition/volume
Dynamic disks are removed with the command “delete volume”. After selecting a partition/volume, use the following line:
delete partition (to delete a partition ofyour choice)
delete volume (to delete a volume of your choice)
Formatting a particular volume/partition
For this, just select the desired partition/volume, and type in Format.