Monday, May 31, 2010

How to Expand a VHD on Hyper-V 2008 R2

This is a fairly basic task that needs to be done fairly frequently, but I've never documented it anywhere so it always takes me 10 minutes longer than what it should. The client where I had to do this today happens to run a HP EVA 4400 Fiber SAN, so I will include the instructions for the EVA side of things as well. Without further ado...

Expanding a existing LUN on an HP EVA 4400 SAN
  1. Log into Command View (HP's delightfully named SAN configuration solution)
  2. Navigate to the the Virtual Disks folder, more specifically to the Vdisk you want to expand
  3. Click the Vdisk, and wait 10 seconds for the incredibly laggy Command View interface to catch up
  4. Type your new, preferred size in the box cunningly labelled "Capacity"
  5. Click "Save"
Expanding a VHD
  1. Use Cluster Resource Manager to determine who owns the Disk Resource you wish to expand
  2. Once identified, go to "Disk Management" on the owner
  3. Right-click the Disk Management node, and select "Rescan Disks". The un-allocated space should show up now
  4. Right-click the volume you wish to expand and select "Extend Volume". Click Next 2 times and finally Finish
  5. Fire up SCVMM and shut down the VM whose VHD you want to expand
  6. Click the "Hardware Configuration" tab, and select the Disk you want to expand
  7. Check the "Expand this disk" checkbox and enter the desired size
  8. Click OK
This should take care expanding the VHD, but this does not mean the underlying OS will automatically make use of the added capacity, no sirrreeee. In my case the VM was running Windows 2008 Server R2, and this is what I had to do....

Using Diskpart to Extend a Partition
  1. Click Start, type CMD and press Enter
  2. In the resulting Command Prompt, type "Diskpart"
  3. Select the correct drive and partition to perform the extend operation on. In my case it was Disk 1, Partition 1. The correct commands in my case were "Select disk 1" and "Select Partition 1". The "List disk" and "List partition" commands, surprisingly enough, will list your existing disks and partitions
  4. Now that we've got the correct disks and partitions selected, we simply give the "Extend" command. This will extend the disk using all the contiguous free space available
And with that done, you should be the proud Admin of a newly extended VHD!