Windows  provides the ability to resize volumes directly from the command line using the Diskpart utility. The Windows Diskpart utility is a command line program for managing the disk partitions, or volumes, on your computer. Some of the tasks you can do with this utility include repartitioning drives, deleting partitions, creating partitions, changing drive letters, and now shrinking and expanding volumes.

To access the diskpart utility follow these steps:

  1. Click on the Start Menu button.
  2. In the Run/Search field type Diskpart and press the enter key on your board.
  3. Windows Vista may ask if you want to allow this program to run and you should press the Continue button.
  4. A command prompt will now open and you will be within the Diskpart console. For a list of commands that you can use within the Diskpart console you can type help. For the help instructions for a particular command you can type the name of the command followed by help, such as select help .

Before you can expand or shrink a volume using Diskpart you must first select the volume you would like to work with. To do this you need to use the list volume command to find the IDs associated with each volume. When you type list volume and then press enter, diskpart will display a list of Windows volumes on your computer. Next to each volume will also be a numbers that can be used to identify that specific volume. An example of what the list volume command looks like can be found below.

List volume in diskpart

After determining the ID of the volume that you would like to work with, you need to select that volume using the select volume command. To use this command you would type select volume ID, where ID is the ID associated with the volume you found using the list volume command. Now that the volume has been selected, diskpart knows that any further commands will be associated with this particular volume until you enter another select volume command.

To shrink a selected volume you would use the shrink command. The shrink command has two arguments that you can use to define how you want diskpart to shrink the volume. The first argument is desired= which will shrink the volume by the desired amount in MB if possible. The second argument is minimum= which tells diskpart that it should only shrink the volume if it can shrink it by the specified amount in MB. If you do not use either of these arguments, diskpart will shrink the partition by the maximum amount possible. If you would like to determine the maximum amount of space that you can shrink a volume, you can type the shrink querymax command.

Shrink examples are:

Command
What it does
shrink desired=2048 This command will shrink the volume by 2 GB if possible.
shrink minimum=2048 This command will shrink the volume as much as possible, but fail if there is less than 2GB available to shrink it by.
shrink This command will shrink the volume by the maximum it can be.

 

Vista Shrink from command line
Shrinking a volume from the command line

To extend a selected volume you would use the extend command. For the extend command the most common arguments are size and disk. The size= argument will extend the selected volume by the desired amount of MB. The disk= argument allows you to specify the disk which has the free space you wish to extend a volume with. If no argument, or no disk= argument, is provided when using the extend command, diskpart will use all the available space on the current disk to extend the volume. As said previously, we strongly suggest that you do not use the disk= argument to extend a volume onto another disk as this increases your chance of losing data if one of the two drives has a hardware failure.

Extend examples are:

Command
What it does
extend size=2048 disk=2 This command will extend the volume by 2 GB using the free space from disk 2..
extend size=2048 This command will extend the volume by 2GB from the same disk.
extend This command will extend the volume as much as it can be.

 

 

 

Online