In addition to the graphical interface that the Disk Management
snap-in provides, Windows Server 2008 R2 also includes a command-line
utility called Diskpart.exe that can perform all the same tasks, and a
few that Disk Management cannot, such as creating a fourth primary
partition on a basic disk.
Diskpart.exe has two operational modes: a script mode and an interactive
mode. To use script mode, you create scripts containing multiple
Diskpart commands and execute them from the command line using the
following syntax:
diskpart /s scriptfile
To use interactive mode, you run Diskpart.exe from the command line
without any parameters. This runs the program and generates a
DISKPART> prompt, as shown in Figure 16.
To use Diskpart in interactive mode, you execute commands from the DISKPART> prompt. Typically, you use various commands to specify what storage resource you want to manage and then use other commands to work with that resource.
For example, to create a new partition on a basic disk, you must
first specify the disk where you want to create the partition. The list disk command displays a list of the disks on the system, as shown in Figure 17.
To work with a particular disk, you use a command like select disk 4,
which shifts the focus of the program to that disk. It executes all
your commands from this point on disk 4, until you change the focus. In
the same way, you can change the focus of the program to a specific
partition or volume on the current disk.
Once you have selected a disk, you can create a partition using a command like the following:
create partition primary size=10000
This command creates a 10 GB primary partition on the currently selected disk. Using other commands, such as add, convert, delete, extend, format, and shrink, you can manipulate disks, partitions, and volumes, just as you can from the Disk Management snap-in.
Note
The Disk Management snap-in is somewhat informal about disk terminology, often confusing the terms partition and volume.
Diskpart.exe is more precise. You cannot create a volume on a basic
disk using Diskpart, nor can you create a partition on a dynamic disk.