How to extend partition for windows 2003 vm in hyper v
How to extend partition/volume on
windows 2003 & windows 2008
running inside a VHD hosted on
You must first completely shut down the virtual machine. You cannot expand a virtual
hard disk that is associated with a running or saved stated virtual machine.
If you expand a virtual hard disk that is associated with a virtual machine that has
snapshots, these snapshots will be invalidated. If you need the snapshots, you'd better
make sure you plan ahead of time, and/or create new snapshots after performing the
expansion of the hard disk.
After expanding the virtual hard disk there will be an empty space at the end of the
virtual hard disk. You will either need to create a new partition to use the new
space, or expand an existing partition into the new space.
There are two options to address 'You are running out of disk space' problem:
Option A- Delete the unwanted files to free up more space, if you could.
Option B- Extend the partition.
Extension process is done in 2 phases for HYPER-V Environment:
Offline mode – Outside VM – After powering down the VM [In the HYPER-V Manager]
Online mode – Inside VM - After powering up the VM.
There three conditions you should check before you start the expansion:
1. Do you fall into this condition?: No virtual machine snapshots – VM on which you are
trying to expand the drive does not have snapshots.
2. Do you fall into this condition?: Virtual machine snapshots exist – VM on which you are
trying to expand the drive does have snapshots.
3. Do you fall into this condition?: If you are expanding C: drive that does not have
contiguous unallocated disk space. Imagine a scenario, where in you have C: drive
followed by D: and you notice there are plenty of spaces with D: that you want to
Depending upon which condition you fall into, take the
Condition 1: [No virtual machine snapshots: You have just single *.VHD file]
Note: You can also go to the CSV volume on which this VM exits and check for *.AVHD’
presence [automatic Virtual Hard Disk exits]. Existence of these files (*.avhd) also indicates
that you have virtual machine snapshots. If you see only one disk *.VHD’, then follow the
Procedure is straight forward –
Follow the standard steps showed in PHASE1 [page 5]
After extending the VHD in HYPER-V, power up the VM & follow these steps given in
Condition 2: [Virtual Machine snapshots exist: You have *.VHD & *.AVHD]
Note: As you know the rule – You can only expand the drive if it is single *.VHD disk.
Solution: Delete the snapshots – This is required, In order to merge the snapshots into
a single disk.
1. Go to the HYPER-V host [whichever host is hosting the VM]
2. Go to desired VM.
3. Delete snapshot.
Select a snapshot and choose the Delete Snapshot action to delete a snapshot.[As
shown in figure below]
To delete a collection of snapshots, select the top snapshot that you want to delete,
and choose the Delete Snapshot Subtree action.
4. Once delete snapshot operation is done, click ‘SHUTDOWN’ [Once the VM is turned off -
It will automatically kick-in snapshot merge process].
5. You should be patient now. Make sure you scroll all the way to the right in order to see
the merge process.
6. Once merge is completed 100%, wait for a minute and then follow the standard
7. Follow the standard steps showed in PHASE1[page 6]
8. Follow PHASE 2.
Condition 3: [C: drive does not have contiguous unallocated disk space] [Note: This is just
an analogy, I have not tested this]
If you have C: 40GB [FULL]
D: 160GB [100GB Free]
Even though you have 100GB free, you cannot extend the C: drive. On Windows 2008, Disk
management tool, when you right click, this option will be grayed out.
Alternative option 1: Backup data on D: partition, delete the partition, reboot, and
then you may extend the boot partition, as explained below.
1- Temporarily move all the Data from ‘D:’ volume to another location.
2- Change the 'D:' drive letter to a different drive letter that is available on the system (for
instance Z :)
3- Shrink 'Z:' to whatever size that you’d like to add it to the 'C:' volume. Let's assume we
4- Create a new volume out of the unallocated space that was taken from ‘Z:’ and assign ‘D:’
as the drive letter.
5- Delete ‘Z:’ volume that will make it an unallocated partition between ‘C:’ and ‘D:’
6. Reboot the server.
7- Extend the C: partition.
Alternative option 2: Look for third-party tools mentioned below.
PHASE 1: [offline mode: VM is Powered OFF/Shutdown]
1. Start | Click 'HYPER-V Manager' [Hyper-V management Console]
2. Once the console is launched, Go to the respective Host on which the VM is hosted,
select the VM that you want to work with, and then from the ‘Actions’ menu on the
right hand side pane, click ‘Edit Disk’, as shown in the figure below.
3. Before you begin screen appears, click ‘Next’.
4. Locate Virtual Hard Disk screen appears – Pay attention here.
Click ‘Browse’ and select the VHD that you intend to extend and click ‘Next’.
5. Select ‘Expand’ and click ‘Next’.
6. Enter the new size and click ‘Next’.
7. Review the change you made and click ‘Finish’.
8. Wait till the operation finishes, this may take few seconds to few minutes.
There are some great improvements in Windows 7/Vista/2008 Disk Management, Compared
with Windows 2000/XP/2003; the advantage of Windows 7/Vista/2008 is that it allows users
to resize partition with "Extend Volume" and "Shrink Volume" using Disk Management GUI
[without using command line diskpart tool].
PHASE 2: [Online mode: VM is powered ON]
To extend a basic disk [Data/System volume] using GUI: [For Windows 7/Vista/2008]
After extending the VHD in HYPER-V, power up the VM & follow these steps:
1. In Disk Manager, right-click the basic volume you want to extend.
2. Click Extend Volume....
3. Follow the instructions on your screen.
PHASE 2: [Online mode: VM is powered ON] [For windows 2003 – Data volume]
As we are extending a volume on a Windows 2003 Server, we have to use the command line
utility to extend the volume; GUI is not an option here.
To extend a basic disk [Data volume] using a command line
Open a command prompt and type diskpart.
At the DISKPART prompt, type list volume. Make note of the basic volume you want to
At the DISKPART prompt, type select volume <volumenumber>. This selects the basic
volume number that you want to extend into contiguous, empty space on the same
At the DISKPART prompt, type extend.
Note: To extend a particular size enter the value [size=<size>]
Now in action [On windows 2003 VM] – Make sure the VM is booted up.
Follow the steps one by one as shown in the screenshot below: [diskpart]
For Windows 2003: [‘C: ’ Extending System Drive]
This is complex: You need Windows Preinstallation Environment (Windows PE) to extend the
drive that contains the Microsoft Windows operating system.
Alternatively, look for the third party tools mentioned in this document.