Give me my space: How to resize Windows Server drives in VMware
- select the contributor at the end of the page -
One of the most common things that a system administrator will have to do in a virtualized environment is give out more RAM, CPU or disk space to a virtual machine. The whole point of virtualization is having the ability to dynamically change these values, but some can need more than a simple reboot, especially when it comes to resizing disks.
I'm going to go through the process of increasing the disk space of a virtual machine running Microsoft Windows Server 2012 running on VMware 5.1 (vSphere 5.1, ESXi 5.1 host and VMware tools installed). Along the way, I'm going to discuss a potential issue that can cause a lot of headaches, but ones that can be avoided with pre-defined guidelines or best practices.
A simple example
Let's start with the simplest example where I have created a Windows Server 2012 VM with a single OS drive of 40 GB. You'll see the Disk Management snapin will show below. Nothing much to see here except one single volume.
Here's what the settings look like for this VM in VMware. We have one single hard disk. The fact that it's configured as “lazy zeroed” is not important, and what I go through here applies to the other two types of disks you'll find (“thin” and “eager zeroed”). Just remember that you won't be able to resize the disk if it has a snapshot.
Let's start off by increasing the size of this disk to 45 GB. You simply need to change the value in the above VM properties to the desired value and click OK. Pretty simple so far. We've increased the size of the underlying disk, but need to do a few things in the operating system now.
The first thing we're going to do is to get the operating system to do a disk rescan, which is really simple to do via the Disk Management console, by simply selecting Rescan Disks.
From here, we'll see an extra amount of disk space show up in the console as “Unallocated.” We have the choice of what we want to do with this unallocated space, but in this example, we want to use this space to increase the current size of the operating system drive.
This shows one of the awesome improvements in Windows Server. In Windows Server 2003, resizing the OS drive wasn't possible, but this changed in Windows Server 2008.
So now that we have our “extra space,” resizing the OS drive is another simple task. Just by right-clicking on the partition, we have an “Extend Volume” option. This will fire up a pretty simple wizard (not shown). For example, you can choose whether you want to use the full size of the unallocated space.
After the wizard finishes, your disk is now resized as you requested. This is all done while the operating system is running, too! This is the magic that virtualization provides. Think about how much effort it would take to do something like this on a physical server.
Bad setup for future increases
Now, let's say we have a setup with two volumes on one single disk. What happens if we need to increase the space of a volume? Does it matter which volume?
Based on the previous example, we just need to resize the disk in VMware, and then extend the volume, right? Here's where we might have a problem.
This is what our disk looks like when we have two volumes on the same disk. The important thing to note is that C: is not the last volume on the disk, while E: is at the end.
If we go through the same kind of process as before (not show again here), we increase the size of the single disk and do a rescan, the result would look something like this:
So, if the goal was to increase the size of the C: drive then by simply right-clicking on the drive, it could be extended as before. Hold on–there's a problem, because when the drive is right-clicked on, the “Extend Volume” option is disabled. Remember that the C: drive is not at the end of the drive.
OK, will I see the same behavior if I tried to extend the E: drive instead, right? Remember that this volume is at the end of the drive. Now I have the “Extend Volume” option available and can use it.
The important takeaway from the previous example is if you are trying to resize a volume, then it either has to be the only volume on the disk or must be at the end of the disk. The problem is that a volume can't be moved by the built-in features.
Guideline: One volume per disk
I want to show you how easy it is to resize a disk, but also to offer a practical example to show how important it is to plan and design virtual machines properly at setup.
A best practice or guideline in a virtualized environment is to look at having a “one volume per disk” policy or guideline. It can save you a lot of trouble in the future, especially in a virtualized environment, where all of a sudden you need to increase the size of a volume.
In the original example above, we had a single volume on a single disk, and then we moved on to two volumes on a single disk.
The better way to setup two volumes on a virtual machine would be to have two disks, so that each volume had its own dedicated disk.
Setting up a second disk
In this next example, if I started off with a system with a single disk, and wanted to add a second disk it would be as simple as adding the proper virtual hardware to the virtual machine as shown below.
I've skipped a few steps between having a single disk/volume to having the setup below where I have my C: and E: volumes on different drives. Once you add a new disk to an existing Windows Server virtual machine you have to bring the disk online, initialize it and create a volume on it (not shown).
This is what a better setup looks like:
In this last example, I don't have any constraints if I need to increase the size of either my C: or E: drives because now they are either the only volume on the disk or are at the end.
Ready to test your skills in VMware? See how they stack up with this assessment from Smarterer. Start this VMware test now.