Windows Volume management

Overview of Disk Management

Disk management is basically about taking a set of physical disks and formatting them into volumes, drives and partitions. You can do this in Windows Server 2016 with the Disk Management GUI, or the DiskPart.exe command line. You find the Disk Management GUI in Server Manager - Storage or by running Diskmgmt.msc from a command line.

However this page will concentrate on using the diskpart.exe command line. Some people prefer to use GUIs to manage their disks, but if you are making a number of changes it is much easier to set the commands up into a script file then run it through a command line. It is also much easier to check the commands this way, before you run them. Fsutil.exe and Mountvol.exe are also command line utilities.

First, some words about windows disk storage in general.

Dynamic disks were developed in conjunction with Veritas software and introduced in Windows 2000 Server. At that time, physical disks were limited in size and were prone to failure. Dynamic disks let you combine several physical disks into one dynamic volume, and form volumes into RAID 0,1 or 5 configurations, stripe the data, mirror the data and dynamically resize volumes, usually without needing a system reboot.

A lot of server disk is supplied behind a RAID controller and you can get this dynamic disk functionality in that controller. The virtualised, striped and RAIDed disk is presented to the Windows system by the RAID controller as a basic disk and then it is much easier to manage at Windows level, especially in a DR situation.

Using DISKPART

It's good practice to always back up the hard disk before running DiskPart.

To access DiskPart, simply type diskpart from a command window

Diskpart.exe works by putting an object into focus, then performing actions on that object. When you select an object, the focus remains on that object until you select a different object. Some commands, like 'create new partition' will automatically change the focus. However, the 'list partition' command only displays partitions on the disk that has focus. When you use the 'list' commands, an asterisk (*) appears next to the object with focus. You can find out what objects exist by using the list commands .

LIST Disk
LIST Partition
LIST Volume
LIST VDSK (Windows 2008 only)

Once you know what objects exist, you put one into focus by selecting it

SELECT Disk=n
SELECT Partition=n
SELECT Volume=n-or-d (Number or Drive Letter)

When you are working with disks and using the select command to target disks on your system, it is important to note how the drives are numbered. Drives are numbered beginning with 0. That means the first drive in your system is drive 0. So, if you wanted to use the select command to select the first disk, the command would look as follows:
select disk 0
Put your commands into a text file with one command per line then run DiskPart with the text file as input. The naming standard below makes it easy to find out what changes were made, and the output is written to a log file. From the command line, execute your script like this

diskpart /s change20170825.txt > change20170825-log.txt

Some sample diskpart scripts include

create new partition

set the focus to disk 0, create a primary partition on it, assign it as drive f: and format it as NTFS

Select disk=0
Create partition primary
Assign letter=F
Select partition=1
format FS=NTFS label="VOL00F" quick
exit

create a new volume

The volume type can be simple, striped or raid. Striped and raid volumes need to span several disks, hence the disks parameter has several device numbers, separated by commas.

CREATE VOLUME Simple Size=n Disk=n
CREATE VOLUME Stripe Size=n Disk=n,n,...
CREATE VOLUME Raid Size=n Disk=n,n,...

extend basic volume

List out the volumes to get the volume numbers, set the volume that we want to extend, then run the extend command. In this case we are extending the volume by 250GB

list volume
select volume n
extend size=250000

shrink basic volume

List out the volumes to get the volume numbers, set the volume that we want to shrink, then run the shrink command. Desired is the ideal new volume size, minimum is the lowest possible size the volume can shrink to.

list volume.
select volume n
shrink desired=100000 minimum=75000

convert volume to dynamic

Convert disk 3 to dynamic, format the disk as NTFS, create a new 500G volume, assign a drive letter of F, and add a label of 'Work Drive' - notice how the select statements change the focus from disk 3 to volume f.

list disk
select disk 3
convert dynamic
create volume simple size=500000 disk=3
assign letter f
select volume f
format FS=NTFS label="work Drive" quick

create a mirrored volume

Convert disk 2 and disk 3 to dynamic, create a mirrored volume of 200GB, assign a drive letter of M, format the new mirrored volume with NTFS, and add a label of 'Mirrored user drive'

select disk 2
convert dynamic
select disk 3
convert dynamic
create volume mirror size=200000 disk=2,3
assign letter m
select volume m
format FS=NTFS label="Mirrored user drive" quick

back to top