Is your Windows Server VM out of hard drive space? It’s always been possible to expand the space you’ve allocated its VM and then run some complicated disk utilities to get Windows to recognize the extra space and (usually) not break the in the process. But ever since Windows Server 2008 you now have a MUCH easier and more reliable way to expand the amount of space you’ve made available to Windows’s primary partition. Weirdly, not as many people know about this as I would’ve expected, so I present it to you here, on the off-chance that you figured there HAS to be a better way, and did a little searching…
Obviously, the first step is to shut down Windows and expand the virtual disk size that you’ve allocated the OS. (I usually use thin provisioning.) Now fire up Windows, and you’ll see it’s still reporting the same amount of free space. Here’s where life got much easier with Windows 2008: Just open an Administrator-level Command Prompt and type diskpart and hit enter.
Now that you’re in diskpart, type list disk and hit enter.
Look at the choices, and determine which disk you want to expand into the free space. In my case I type: select disk 0
Now type list volume and hit enter. (Or you can also do list partition instead),
Tell it which volume you wanted expanded by typing select volume 0 (or whatever your volume number is) and hitting enter. (Or you could do select partition 0 instead.)
Finally, just type extend and hit enter to expand into the unused space.
Type exit to get out of diskpart, and when you do a dir you’ll see the newly available space ready to use!
(Just to be safe I like to reboot and check the disk for errors to make sure everything’s happy, but this is totally optional.)