There are occasions when one need more disk space on a Windows Core machine, for example, to install that pesky Service Pack. As it is often the case, the Windows machine is a virtual machine, such that additional space can be allocated to the VM simply by adding to the size of the virtual disk. But, how does Windows recognize this space, and incorporate it into the filesystem? Normally, one would go into the Disk Management MMC, and simply expand it there. But, of course, this MMC is not available on Windows Server Core.
To manage disks and partitions on Server Core, use the diskpart.exe command-line utility. Assuming your machine does have unused space on the disk, lets go thru an example of how to expand the C: partition. Log into your core box, and type “diskpart” at the command prompt. This drops you into the diskpart command shell, and noted by the prompt.
C:\>diskpart
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: CoreBox
DISKPART>
From here, lets have a look at the disks that the OS recognizes:
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 20 GB 0 B
DISKPART>
But, we’re not seeing any free disk space to expand into. But we know that the ESX admin gave us more space on this disk. Why don’t we see it? We will need to rescan the disk subsystem.
DISKPART> rescan
Please wait while DiskPart scans your configuration…
DiskPart has finished scanning your configuration.
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 25 GB 5120 MB
DISKPART>
So, now we can see our free disk space.
Lets select the disk so that commands know which disk object to perform the action on.
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART>
Be careful to not assume there is only one partition on the disk. There is generally a “System Reserved” partition, and we want to be sure to expand the appropriate partition. Lets look at the partitions:
DISKPART> list partition
Partition ### Type Size Offset
————- —————- ——- ——-
Partition 1 Primary 100 MB 1024 KB
Partition 2 Primary 19 GB 101 MB
DISKPART>
Partition 2 is the one we want to grow. So lets select it:
DISKPART> select partition 2
Partition 2 is now the selected partition.
DISKPART>
Now, we can extend this partition into some, or all of the free disk space. The “list disk” command above is used to know how much free disk space is available.
DISKPART> extend <— extends the partition into all of the free disk space
DiskPart successfully extended the volume.
DISKPART>
or,
DISKPART> extend size=2560 <— extends, say, into half the available free disk space
So now, the C: drive is bigger. yay! Typing “exit” drops you back to the Windows command prompt:
DISKPART> exit
Leaving DiskPart…
C:\>
There are more management options in diskpart:
DISKPART> help
will show a list of all the options. Remember that with DISKPART, one has to select the object before an operation can be performed on it. To know which object is currently selected, look for the asterisk next to it when listing the relevant objects.
DISKPART> list partition
Partition ### Type Size Offset
————- —————- ——- ——-
Partition 1 Primary 100 MB 1024 KB
Partition 2 Primary 24 GB 101 MB
DISKPART> select partition 2
Partition 2 is now the selected partition.
DISKPART> list partition
Partition ### Type Size Offset
————- —————- ——- ——-
Partition 1 Primary 100 MB 1024 KB
* Partition 2 Primary 24 GB 101 MB
DISKPART>
Now, maybe we can install that Service Pack….