Windows Server Core Expand Volume

I am trying to run as many of my Windows server home lab virtual machines (VM) as Core installs. This reduces the resource requirement for each VM in terms of drive space, memory and CPU – obviously a good thing in any environment. It also forces me to learn more ways of dealing with situations, in this case how to expand a volume from the PowerShell prompt on the VM.

It is of course possible to connect to a VM from another server/client running a GUI and use the standard disk management MMC console to expand/manage the disk on the remote VM. In this case though I wanted to see how it would be done direct via the command line.

 

Check Current Volume Size

To see how much space I have on the VM volumes we can leverage the Get-Volume PowerShell cmdlet.

PS C:\> Get-Volume

Get-Volume PowerShell Command

 

As you can see I have an E:\ drive which only has 4KB of space available. This VM is my Windows Server Update Services (WSUS) server and obviously the amount of updates I’m synchronising is more than my available disk space so it’s time to expand.

 

Expand Volume

The first thing I did was expand the disk capacity by 60GB in the hypervisor – in this case VMware ESXi. Having done that I went back to the VM and used DISKPART to do a rescan to make sure the VM was aware of the change.

PS C:\> diskpart

DISKPART> rescan

DISKPART rescan

 

Next we will create a PowerShell variable and bind the maximum volume size to it.

PS C:\> $MaxSize = (Get-PartitionSupportedSize -DriveLetter E).sizeMax

$MaxSize = (Get-PartitionSupportedSize -DriveLetter E).sizeMax

 

Now we will use the Resize-Partition PowerShell cmdlet to extend the E:\ volume to the maximum size as defined in our previously created variable.

PS C:\> Resize-Partition -DriveLetter E -Size $MaxSize

Resize-Partition -DriveLetter E -Size $MaxSize

 

As you can see when I ran the Get-Volume cmdlet the additional 60GB of disk space I allocated shows as available for this volume.

 


I could have done all the above through a GUI but it’s really important to me that I learn more of the PowerShell methods as I ultimately want to transition everything I can at both home and work to Server Core and when it arrives Nano server.

If you have a different way of handling the above or would like to know more drop a comment below.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.