• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1229
  • Last Modified:

Hyper-V - copying dynmaic VHD to fixed VHD

I have a 2008 R2 HyperV Dynamic VHD. I want to copy it to a blank Fixed VHD I've created.  ? I know I could do it with Ghost. Are there any other strictly Windows methods I could use to achieve the same effect?
0
lineonecorp
Asked:
lineonecorp
  • 4
  • 2
  • 2
  • +1
3 Solutions
 
Syed Mutahir AliTechnology ConsultantCommented:

http://joeelway.spaces.live.com/blog/cns!2095EAC3772C41DB!1748.entry

If you use Hyper-V without Virtual Machine Manager 2008 then you can do this using the Hyper-V console.  Edit the virtual machine in question (if applicable), select the disk and click on .  Choose to convert the disk.  You'll then be asked where to place the new disk.  Be wary here if you use dedicated volumes for each VM, e.g. in a Windows 2008 cluster.  There may not be enough disk space in the existing disks volume for the new fixed sized disk that will be created - that's correct; it doesn't convert the disk, it creates a new one.  Choose a suitable temporary location and name.  For example, my VHD might be called Disk0.VHD and I'd convert to Disk0Full.vhd.  When finished, I'd rename them, e.g. Disk0.VHD -> DiskDyn.VHD and Disk0Full.VHD -> Disk0.VHD.  Swap the files and then restart the VM.

It's both easier and more complex using VMM.  You can select the VM in question and select the disk.  Tick the box for "Convert to Fixed Type Virtual Hard Disk" and apply the changes.  A new job will start.  This creates a new VHD in the same volume as the existing VM.  That's a bit nasty.  You tend to limit the size of the LUN in question to avoid wastage when using a cluster.  So odds are, this will fail unless you've plenty of spare space in the LUN - remember the LUN will contain both the original dynamic disk and the converted fixed size disk for at least a short period of time.  Temporarily increasing and decreasing the volume size should not be done, even if your SAN can do it ... my testing phase showed that it corrupts the contents of the volume.  The nice bit of this process is that all the file renaming and swapping is done for you.  I just wish you could pick a temporary location for the file conversion process.  That might be possible using PowerShell.
0
 
lineonecorpAuthor Commented:
We found a problem with the conversion business.  We originally had a physical drive that we imported into a Dynamic VHD - the process shrunk the drive in the process in the sense that unused space in the original physical drive was mapped out of the Dynamic VHD - it 'shrunk' the drive. We then wanted to convert it to a fixed size that was bigger than the conversion to Dynamic had allocated but less than the original physical disk size. However, the conversion wanted to create a fixed disk as big as the original physical disk. So what I want to do is create the Fixed VHD a specific size and then copy the Dynamic to that VHD.  With Ghost I have the option to make the target a different size than the source so it would do what I want. I just wanted to see if there was a way to do it with Windows. Do you know of a way to duplicate the Ghost trick with just Windows?  Or alternatively do you know of a way I can convert the Dynamic to a specific Fixed size in my situation so that it doesn't revert to the original physical size?
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
lineonecorpAuthor Commented:
As I wrote earlier, that's what we tried to do and it would only create a fixed VHD that was the same size as the original physical disk. In other words let's say we started with a physical disk that was 200 gig. When it was imported and converted to a Dynamic VHD the Dynamic VHD was 100 gig.  When we then tried to convert it to let's say 150 gig Fixed VHD it wouldn't allow it  - it wanted to create a Fixed VHD that was at minimum 200 gig - the original physical disk size.
0
 
Syed Mutahir AliTechnology ConsultantCommented:
how much space does it shows as used when you boot up with a dynamic vhd in the virtual machine ?
You can try a test,
create a fixed vhd, convert it to dynamic and then convert it to fixed disk to see what happens, I suspect its because it has set itself a marker of some sort so it won't reduce to your specified size.
the test can reveal that ; i haven't got a hyper-v box at the moment as i am travelling but I will try to check this asap and will post back.
0
 
lineonecorpAuthor Commented:
I'll see about trying the test and wait for you when you get back.
0
 
lineonecorpAuthor Commented:
I will give this a try hopefully this weekend if I can schedule some down time.
0
 
msmamjiCommented:
For VHD Resizer to work, the volume/partition needs to be shrunk. There are a limitation here. Shrinking of a volume is not supported on all Windows OS (if I remember correctly) like Windows Server 2003 and earlier.
Secondly, Shrinking is a basically defrag operation followed by marking the new volume limit. So if there are some unmovable files anywhere in the volume, you wont be able to shrink beyond that.
Once you shrink the volume, VHD Resizer recognize, unallocated space and lets you resize the vhd to that point. Which brings me to my point.
Both VHD resizer and convert disk (in Hyper-V) option check the volume size( as the VM see it) and only allow to resize (shrink) to space used by partition(s) on the volume, i.e  unallocated space can be redeemed.
You might have noticed that using Ghost to make a new resized VHD and then booting the VM, you see the VM's OS complain that volume size has changed (without its knowledge). Which can be risky, if you delete the source VHD without checking the destination VHD first. Only to find out that destination VHD corrupted.

Hope that helps.
P.S: Excuse me for using too many brackets.
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now