How to extend partition for windows 2003 vm in hyper v

4,496 views

Published on

How to extend partition on windows 2003/2008 running inside a VM on HYPER-V host.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,496
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

How to extend partition for windows 2003 vm in hyper v

  1. 1. How to extend partition/volume on windows 2003 & windows 2008 running inside a VHD hosted on Microsoft HYPER-V. IMPORTANT CONSIDERATION For HYPER-V  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.
  2. 2. 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 use it. Depending upon which condition you fall into, take the appropriate procedure. 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 below: 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 PHASE 2. 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. Procedure:  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. 3. 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 expansion process. 7. Follow the standard steps showed in PHASE1[page 6] 8. Follow PHASE 2.
  4. 4. Condition 3: [C: drive does not have contiguous unallocated disk space] [Note: This is just an analogy, I have not tested this] For example: 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 want 80GB. 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:’
  5. 5. 6. Reboot the server. 7- Extend the C: partition.  Alternative option 2: Look for third-party tools mentioned below. http://www.partition-magic-windows7.com/res/extend-volume-windows-7.html http://www.extend-partition.com/extend-system-boot-partition.html http://www.petri.co.il/the-ultimate-guide-to-hard-drive-partitioning.htm http://www.partition-tool.com/partition-magic/resize-partition-windows-server-2003.htm http://www.extend-partition.com/download.html
  6. 6. 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’.
  7. 7. 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’.
  8. 8. 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.
  9. 9. Filesystem extension 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 extend.  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 disk.  At the DISKPART prompt, type extend. Note: To extend a particular size enter the value [size=<size>]
  10. 10. 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. http://support.microsoft.com/kb/911896 Alternatively, look for the third party tools mentioned in this document.
  11. 11. Hyper-V 2008 R2 Virtual Machine Snapshots: FAQ http://social.technet.microsoft.com/wiki/contents/articles/211.hyper-v-2008-r2-virtual- machine-snapshots-faq.aspx Courtesy: http://www.petri.co.il/expanding-virtual-hard-disks-with-hyper-v.htm Courtesy: http://blogs.technet.com/b/mghazai/archive/2009/02/24/extend-system-boot-volume-on- windows-server-2008-windows-vista-win7-beta.aspx What is VHD & VHDX? [A worth read] http://blogs.technet.com/b/yungchou/archive/2013/01/23/hyper-v-virtual-hard-disk-vhd- operations-explained.aspx ashwinwriter@gmail.com

×