none
How to copy a virtual drive RRS feed

  • Question

  • I saw a few of the related topics but none really answered my question. Here's the issue: I have a Windows Server 2012 virtual machine Hyper-V with Microsoft Exchange installed on it. Long story short, I made the boot drive way too large, and it won't let me compact it now.  It also has a data drive for the mailbox database.  What I'd like to do is just copy the contents of the original boot drive into a second much smaller boot drive, connect this VM to the new boot drive, and then delete the old drive.

    What's the best way to do this? 


    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, September 30, 2014 6:29 PM

All replies

  • In a Server 2012 R2 VM, here are the steps (no copying is needed):

    1. In the VM, in computer Management/Disk Management, right-click on drive c: and Shrink volume: 
    2. In Hyper-V Manager Edit the vDisk and Shrink the Volume: 

    If this is a Gen 2 VM, no need to down the machine to shrink or expand boot/system disk. This is due to the fact that it is on a SCSI controller. 

    If this is a Gen 1 VM (Boot/system disk on IDE controller), you'll need to down the VM after you shrink the disk in the VM, and before you can shrink it in the Host.


    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx



    • Edited by Sam Boutros Tuesday, September 30, 2014 7:34 PM Added updates regarding Gen1/Gen2 differencesI
    Tuesday, September 30, 2014 6:38 PM
  • First off, the GUI you posted is for Windows Server 2008.  This server is 2012 and Disk Management is run through Server Manager on a different GUI.

    Second, there is no option to Shrink the drive in Disk Management.  Only to Extend.

    Furthermore, when I try to Compact the .vhd in Hyper-V, it spits out an error.  A rather nasty one which tends to crash all of Hyper-V.

    Which leads me to think the best option is to just create a new .vhd, copy the contents onto it, and boot the machine with the new boot .vhd.


    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, September 30, 2014 6:49 PM
  • In fact, now that I look at it, nowhere do I see an option to Shrink - only Compact, Convert, and Expand.  Does the .vhd have to be formatted in a certain way to allow a Shrink option? 

    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, September 30, 2014 6:54 PM
  • First off, the GUI you posted is for Windows Server 2008.  This server is 2012 and Disk Management is run through Server Manager on a different GUI.

    The images posted are from a 2012 R2 VM.

    In 2012 R2 Server Manager, click Tools\Computer Management to get to Computer Management GUI:

    Second, there is no option to Shrink the drive in Disk Management.  Only to Extend.

    In 2012 R2 there is - see screen shot in my first post. If that option is not available in Server 2012, you can either upgrade to 2012 R2, or use 3rd party tools to either shrink the disk in the VM, or do an offline disk clone with resize.

    Furthermore, when I try to Compact the .vhd in Hyper-V, it spits out an error.  A rather nasty one which tends to crash all of Hyper-V.

    Shrink and Compact are 2 different things. Compact is a process that applies to dynamically expanding disks only, and reclaims disk space occupied by the VHD(x) file that has been deleted inside the VHD(x). Compact must be done on offline disks, not ones that are being actively used by Hyper-V. Compact is not what you want here.

    Shrink is a process that reduces the size of a VHD(x) file. In a fixed VHD(x) file you'll see the size reduction on the Hyper-V host. In a dynamic VHD(x) file the actual file size will remain the same, but the size seen by the VM will show the new reduced size. This is what you should be doing. If the guest OS (VM) has a partition on that VHDX that's taking all the space presented by the hyper-V host, the "Shrink" option won't be there. Hence, you must shrink in the guest OS first, then go out to the host and shrink it there as well.

    Here's an example of a Gen2 2012 R2 VM that I've shrunk its boot/system disk in the VM and on the host - with no down time:

    The Shrink Process has nothing to do with how the disk is formatted in the guest OS. All it needs is free space (in 1 GB increments) on the VHDX file.

     


    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx



    • Edited by Sam Boutros Tuesday, September 30, 2014 7:57 PM
    Tuesday, September 30, 2014 7:28 PM
  • Oh okay thanks.  Well, I was able to shrink the drive within the OS, but when I go to Edit the .vhd file, the shrink option still doesn't exist.  Let me fiddle around with it a bit more and see what I can come up with.  I may need some advice with a decent third party tool to shrink the .vhd.

    Also though I was able to shrink the drive within the OS, it would only let me shrink to 500GB even though the drive had less than 100GB of data on it.  I've had this problem before.


    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, September 30, 2014 10:49 PM
  • Yeah I'm not seeing a "shrink" option in any of my Hyper-V instances.  I have one running on Windows Server 2012 and two running on Windows Server 2008 R2. 

    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, October 7, 2014 1:00 AM
  • For Hyper-V support, you should really be using the Hyper-V forums: http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverhyperv

    this forum is for Virtual Server 2005, which is in no way related to Hyper-V.

    Tuesday, October 7, 2014 2:55 AM
  • Great thanks!  I couldn't navigate to that topic from the root forum, so I just figured this was the next best place to ask.

    ----------- Ron E Biggs Network Administrator Entertainment Studios

    Tuesday, October 7, 2014 7:06 PM