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 Smile 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 Smile

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

image

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

image

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 (http://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

image

  • Start Server => Login as an administrator
  • Start => Right-Click My Computer => Select Manage
  • Expand Storage
  • Click Disk Management
  • Notice the unallocated space

image

  • 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

image

  • 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

image

  • Click Finish on the summary screen and like magic your disk is extended

image

  • 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

image

  • 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 Smile)

image

  • You should already be in Hyper-V Manager with the machine properties open
  • click on IDE Controller 0
  • click Hard Drive
  • Click Add

image

  • Browse to the disk you expanded earlier and select it
  • Make sure it is attached to IDE Controller – click OK

image

  • 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

image

 

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 http://ITProGuru.com/contact.aspx to let me know. To keep from missing other posts, make sure you add an RSS tomy blog.