Hyper-V, can anyone help a n00b?

Soldato
Joined
5 Apr 2004
Posts
5,461
Location
Bloxham
I'm completely new to servers, got myself a test machine from work and installed Server 2008 R2 and just having a play around, mainly with VM's at the moment as I'm trying to knock up a few Win7 VM's in different VM programs so I know the basics of each. I'm then going to use the Win7 VM's for some MS desktop courses for work.

So... I've successfully created a Win7 VM in Hyper-V which wasn't too taxing, however I specified a 40GB drive for this machine during the setup. I now realise I don't need anywhere near this disk size for the machine as I'm not really going to install anything on it, just play with it/break it during my course exercises. I can't seem to find how I reduce the size of the HDD though and I'm getting all confused :(

The actual size of the .VHD file is ~13GB which is I assume the Win7 install, however the disk size shown in Disk Management having started the Win7 VM is 40GB. How can I reduce this to say 20GB?
 
I see, I guess that means that there's 40GB there should that VM want/need it, but if it doesn't then the host machine or other VM's can have it instead?
 
I assume that's when you'd convert the VHD's to fixed disks to stop everything fighting over the same physical HDD space on the host?
 
Out of interest then, how would I go about reducing the size of the HDD of the Win7 VM? I've had a Google but most of the results I've found go a bit over my head.
 
Out of interest then, how would I go about reducing the size of the HDD of the Win7 VM? I've had a Google but most of the results I've found go a bit over my head.

Generally you start small and increase if you don't know how much it'll use. Going backwards is more difficult.
 
On the guest operating system's Disk Management section of Control Panel, doesn't it show the full 40GB (or whatever you've set as the maximum size) even when the actual virtual hard drive file hasn't increased to that size yet? If so, you should be able to resize the partition from the guest operating system.

Or have I got that wrong, and the guest OS shows whatever size the VHD is at that stage?

***edit***

I am thinking right. So surely you can just go into disk management on the guest OS, and resize the partition to 20GB? There should be an option in the Hyper-V VM management software to reduce the size of the VHD so you can do that once the guest OS has had the changes made to take it into account. I'll check that when I'm back on my own computer (running Win8 with a WinXP guest running under Hyper-V) later tonight.
 
Last edited:
On the guest operating system's Disk Management section of Control Panel, doesn't it show the full 40GB (or whatever you've set as the maximum size) even when the actual virtual hard drive file hasn't increased to that size yet? If so, you should be able to resize the partition from the guest operating system.

That's correct but shrinking a OS partition doesn't always work as seamlessly as it should.
 
I tried that while I was playing around, I shrank the guest OS HDD down to 20GB but it just left xGB of space as unallocated. How do I then shrink the VHD within Hyper-V to eat up that unallocated space?
 
I tried that while I was playing around, I shrank the guest OS HDD down to 20GB but it just left xGB of space as unallocated. How do I then shrink the VHD within Hyper-V to eat up that unallocated space?

It shouldn't matter that it's unallocated though, thinking about it? Because the guest OS can't touch it, and the VHD can't grow beyond what the guest OS can write to, the VHD should stay as 'small' as your guest partition.

Maybe.

:D

I'll be back home around half 9 with any luck, so I can pop onto my own computer and find out a) if it's possible to alter the size of the VHD from Hyper-V's management software and b) exactly how you do it :)
 
Hmm. A quick potter around with Google suggests that it's actually really hard to shrink a VHD with Hyper-V, but they tend to be talking about fixed size VHDs (i.e. not ones that dynamically expand as the guest OS gets added to). I think you've been saved by having a dynamic VHD - so what I wrote in post #13 ought to work for you. Shrink the partition in the guest OS, forget about the unallocated space, and the VHD size should stay below or equal to your new partition size in the guest OS.

Now all you have to worry about is the guest OS not screwing up when you resize it's partition! But since it's Windows 7, you *should* be okay.
 
Right, back on my own computer now.

It looks to me as though you cannot shrink the VHDs from the Hyper-V manager - only make them bigger, or convert them between dynamically expanding and fixed size. I'm still thinking that what I said in posts #13 and #15 is correct, and that if the guest OS partition is slimmed down then the dynamically expanding VHD won't grow beyond that partition size. I will test this for you if you like, but it'd have to wait until tomorrow as I've got a few things to do tonight!
 
No probs JRS, thanks for your time mate. I did some Googling and had a play with the Hyper-V settings before I created this thread and found the options you mention regarding converting & expanding the disk, just nothing to reduce the size. As you say it won't grow beyond 20GB if I shrink the volume in the host OS, I just wanted to know if I could tidy it all up nicely cos I'm a bit OCD like that :p
 
Whilst we are on the subject of hyper-v in this thread, I also just installed Server 2008 R2 on my microserver (planning to use this as a hyper-v server)

I carried out a server core installation as this is what google seems to be telling me to do rather than use the GUI as it will be better on performance?

Current Set-up

HP Microserver NL36
8GB RAM
1 x 250GB HDD (one whole parition)
1 x 500GB HDD (which has a couple of partitions on and data that I want to use)
 
Last edited:
Back
Top Bottom