Out of Disk Space on Drive C–How To Increase Space on Drive C of a Virtual Machine Running Windows Server 2003
Revised 4/2/2011 to add merge change instructions link and link to simple way to do this using diskpart. I documented the process at: How To Expand and Extend To Increase Capacity On A Virtual Hard Disk The Easy and Fast Way–Solve the problem of “Out of Disk Space on Drive C” Forever
Note… this is much, much easier with Server 2008 and higher I finished working on an easier way to do this that does not require SCVMM. This easier way to increase capacity was documented at: How To Expand and Extend To Increase Capacity On A Virtual Hard Disk The Easy and Fast Way–Solve the problem of “Out of Disk Space on Drive C” Forever. Thanks to all that asked me to do this
There are two parts to this problem. The first is making the VHD larger. The second is expanding the boot partition to use all the new space. In this example, I am actually going to use features built into Windows Server 2008 to extend the volume of my Windows Server 2003 Boot partition by simply attaching it to the server as a data disk, doing the work on it then reattaching it to the 2003 server.
Part I - Making the VHD Larger
The first part is pretty easy using System Center Virtual Machine Manager. Since SCVMM uses PowerShell for everything, you can do this with PowerShell but I did not do the leg work to come up with the specific commands. Here is what you would need to do with SCVMM.
- You will need to shutdown the server.
- Login to your SCVMM console;
- Double-Click on the server you want to modify
- Click on the Hardware Configuration Tab
- Click on the drive you want to expand
- Turn on the checkbox to Expand virtual hard disk”
- In the size box put in the size you want to make the new drive
- Note: if this is a dynamically expanding disk, it will not actually expand the disk, it only expands the capacity
- Note: if you have a disk “chain” you will need to merge the chain before this option is available. for information on how to merge a chain see How To Merge a Chained Differential VHD Disk So It Can Be Extended and Expanded.
Now login to the server and open disk manager. You will see that you have successfully made the VHD capacity larger by adding unallocated space to the end of it.
- Start Server => Login as an administrator
- Start => Right-Click My Computer => Select Manage
- Expand Storage
- Click Disk Management
- Notice you now have new unallocated space
Part II – Extending The Boot Volume To Use The Full Larger VHD Unallocated Capacity
Since this is a boot volume I am really limited on what I can do with it. I can Convert the Basic disk to Dynamic Disk but this would not solve my problem because you cannot extend the volume of an OS drive.
NOTE: Best practices for using dynamic disks on Windows Server 2003-based computers, DiskPart cannot be used in my case because this is a boot volume. If it is not a boot volume you can use DiskPart. To do this you would follow 325590 (https://support.microsoft.com/kb/325590/ ) How to use Diskpart.exe to extend a data volume in Windows Server 2003, in Windows XP, and in Windows 2000. You cannot extend the partition of an OS disk using diskpart so I am going to attach my boot disk to another server that has extend capabilities.
The only way I could figure out how to pull this off (without third party tools) is to mount the VHD on a windows Server 2008 or later machine and just extend it there. However, snapshots are a problem so you can only do this with a single VHD without any snapshots.
CAUTION: This is NOT supported so proceed at your own RISK. To do this:
- Before you Begin
- Shutdown the VM
- backup the VHD to be expand
Add an additional disk to an existing Windows Server 2008 or 2008 R2 machine, use the VHD you want to expand. Make sure you attach it to an IDE controller (not SCSI)
- Launch Hyper-V Manager
- Double-click machine you will use to extend the VHD
- click on IDE Controller 1
- click Hard Drive
- Click Add
- Browse to the disk you want to add and select it
- Make sure it is attached to IDE Controller - click OK
- Start Server => Login as an administrator
- Start => Right-Click My Computer => Select Manage
- Expand Storage
- Click Disk Management
- Notice the unallocated space
- Right-Click the partition of the disk that you need to extend (in my case it is Disk 0) G: Partition
- Select Extend Volume… from the menu
- This will kick off a very simple wizard
- Just click Next on the information page
- Adjust the size if you like. It should default to the maximum allowed on the disk. Then select Next
- Click Finish on the summary screen and like magic your disk is extended
- Now you need to detach it from the 2008 box and reattach to the 2003 box.
- Shutdown the server so you can remove the disk (on Windows Server 2008 R2 Host you can hot remove storage without shutting down)
- Launch Hyper-V Manager on the HOST
- Double-click machine you used to extend the VHD
- click the Hard drive we just extended
- Click Remove
- DO NOT SKIP THIS STEP!!!!
- We have to login to Hyper-V manager host of the 2003 server and Remove the disk. If you skip this step you will likely get a bunch of security error messages when you boot the VM and the boot will fail. If that happens just come back and do this step. When you create the disk Hyper-V manager adds the security settings that are needed for the VHD.
- Launch Hyper-V Manager on the HOST (of the 2003 machine)
- Double-click your 2003 machine
- click the Hard drive (for the drive we are extending)
- Click Remove (you are removing the pointer to the drive not the VHD file / you should have a backup anyway )
- You should already be in Hyper-V Manager with the machine properties open
- click on IDE Controller 0
- click Hard Drive
- Click Add
- Browse to the disk you expanded earlier and select it
- Make sure it is attached to IDE Controller - click OK
- Now you should be able to successfully start the 2003 machine
- It will ask you to reboot to work with new hardware. I would go ahead and dot it now but you can check the drive first if you like
This took many hours to write so I hope someone finds it useful!
If anyone knows the PowerShell commands to extend the volume, please post to a comment. Thanks
If you like this post, please contact me on Twitter @ITProGuru or send me an email at https://ITProGuru.com/contact.aspx to let me know. To keep from missing other posts, make sure you add an RSS to my blog.
Comments
Anonymous
January 01, 2003
The comment has been removedAnonymous
March 07, 2011
You can extend on the fly (like with 2008) using the ExtPart tool from Dell. 32-bit only though, but very handy!Anonymous
April 02, 2011
I expanded and extended the disk (increase capacity)using diskpart and documented the process at: How To Expand and Extend To Increase Capacity On A Virtual Hard Disk The Easy and Fast Way–Solve the problem of “Out of Disk Space on Drive C” Forever. http://blogs.technet.com/b/danstolts/archive/2011/04/02/how-to-expand-and-extend-to-increase-capacity-on-a-virtual-hard-disk-the-easy-and-fast-way-solve-the-problem-of-out-of-disk-space-on-drive-c-forever.aspxAnonymous
April 18, 2011
Thank you for taking the time to document this procedure. Worked for me with the following tips:
- It's helpful to label/name the drives first, for example "Server1-C".
- Remove the drive from the 2003 machine at the beginning of Part II.
Anonymous
September 23, 2012
Thank you very much - very helpful when expart doesn't workAnonymous
November 12, 2012
Thank you for taken time that written the document, very helpful.Anonymous
December 11, 2012
You're the best, thanks for all the info. Helped me out a lot!Anonymous
December 13, 2012
Good article, well explained! I've found this one really good for doing the same, except using VMware instead of Hyper-V and also Windows Server 2008. www.rootusers.com/increasing-disk-space-in-windows-server-2008 Thanks again :)Anonymous
January 31, 2013
excellent post, worked like a charm!Anonymous
September 23, 2014
Thanks, this pointed me in the right direction:)Anonymous
June 23, 2015
Thanks so much, it worked perfectly!Anonymous
December 03, 2015
The comment has been removedAnonymous
December 19, 2015
Thanks so much for writing this. I was racking my brain on how to increase hard drive space on my Server 2003 VM in order to defrag the exchange database inside. This article jogged my memory - simply shut the VM in question down, and from within the Server 2008 Host, attach the VM in Disk Manager. Then Extend. Then detach, and fire up the 2003 VM, work perfectly, took 3 minutes.