VHD is much larger than the actual server


I have an Exchange 2010 server running as a guest on a hyper V virtual host.  

I see the .vhd for this server is 296,384.120kb on the HyperV host.  This doesn't seem to change, including when I recently deleted 35GB of files from the Guest Exchange vm and the file size changed to 296,367,740 after a reboot...  

On the Guest Exchaneg server itself, the "C" drive (only drive on the sys) is set to 499GB, with 78.6GB used.

I believe my Hyper V is a fixed disk setup within Hyper V (but not 100% sure...).  Perhaps its as simple as I somehow told this file to be 300GB?  I'm not sure how to confirm this?  

There was some snapshots for this server, which I deleted from Hyper V manager, and let the server merge them on my next shutdown.  This was successful.  

In addition, I saw within Hyper V manager an option to "edit" disk where you select a .vhd and there is an option to "compact" it...but I have to say this option has a "scary" sound to it...

Is the "compact" option mentioned above feasible / worthwhile...or risky...?

Any ideas as to why this .VHD is so large, and what can be done to get it to more "reasonable" size considering the data is less than 100GB right now?  I have confirmed there are no more snapshots in place, restarted the guest and the whole Hyper V host.  

Tips appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about using VHDResizer from vmtoolkit.com?
mikeshaverAuthor Commented:
I appreciate the tip, but I'd like to know "why" its the size it is?
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Darius GhassemCommented:
Most likely the VHD is a variable disk which will give the results you are seeing. If you compact the disk this will remove the deleted space or empty space within the VHD.

mikeshaverAuthor Commented:
Thanks guys. How can I verify if I have a fixed or variable disk?
Darius GhassemCommented:
Trying to remember but if you go to the Edit VHD I believe it will tell you. I don't have my Hyper-v in front of me. Or try going to VM settings to see if the information tells you that VHD is fixed or dynamic
Under Hyper-V manager one of the actions on the right pane is Inspect Disk, which will tell you the type of disk, current size, and maximum size. If it's a fixed disk it will tell you size. If it's a dynamic disk you can compact it which is safe, but you require lots of free space and it is an offline operation. It sounds like you have a dynamic disk and it will continue to grow as the VM writes to different parts of the disk. The only thing you can do to prevent it from growing to possibly 500 GB is to resize the disk to something smaller/copy to a smaller VHD.
Greg HejlPrincipal ConsultantCommented:
every vhd for exchange server must be a Fixed Disk.

programs that perform many r/w will make a dynamic disk grow out of your hardware limitations and cause your application to fail.

imho dynamic disks should not be used.  I haven't met one yet that has not needed a 'visit' to perform maintenance.

the read/write operations of databases and mailboxes creates white space in the VHD where data is not written.  the compact operation resets the white space to write-able area and shrinks the disk to the actual size of the data.

it's safe to run this anytime - the VM has to be off during this operation.

VM OS vhd's should Never be dynamic - your VM will eventually fail - then you'll have to spend all day copying to fixed and unattaching/reattaching to manipulate the OS vhd

A fixed disk behaves most like a physical disk.
mikeshaverAuthor Commented:
When I click on "inspect disk" in the Hyper V Manager, it brings up basically a "my computer" window for the local C drive on the Hyper V host (no san for this server).  It shows me that I  have 409GB of 743GB free.  Exactly what right clicking / properties on the drive in My Computer on the host.  

I'd say this means the Host disk is a "fixed disk"?  

If I run the "edit disk" from Hyper V Manager, i browse to the location of the large .VHD, the options there are "compact, convert, and expand."  The convert option indicates "this option converts this dynamic virtual hard disk to a fixed virtual hard disk by copying the contents."  

Based on this...I'm assuming my .VHD must be a dynamic disk?  

If this is the case (its a dynamic disk), it seems my best option is to convert this to a fixed disk.  If thats is the case, is there much risk here....should I shut the VM down to do it to be the most safe?  This is an exchange 2010 running server.

Lastly, before I run the "convert" (assuming thats what I'm going to do) is there any use in copying the current .vhd's somewhere first in case things go horribly awry...could I use them to recover in a panic?

Anything I need to "watch out for" if I do this conversion...?


Greg HejlPrincipal ConsultantCommented:
yes you have a dynamic disk.

if this is a 'data' disk the procedure is straight forward.  shut down the VM. compact the disk.  convert to fixed.

the fixed disk conversion process is a copy operation.  you have to have enough space to make the copy.

on a couple of my machines i did this on I had to attach a USB drive to copy the fixed vhd - then remove the dynamic and copy the fixed back to the server drives.

mikeshaverAuthor Commented:
By "data" disk...do you mean NOT the actual server / os...?  The one in question is an Exchange 2010 server running Server 2008R2, which is the one I'm most concerned about.  
mikeshaverAuthor Commented:
I just ran this on a server I don't really care about as a test.  Seemed to go fine, size is alot smaller now.  

The conversion didn't ask for a "size" for the fixed disk though...should I be concerned?  How does it "know" what the size of the fixed disk should be...I don't want it to fill up on me if its too small...?
mikeshaverAuthor Commented:
OK, I lied....the "fixed" disk is WAY larger than the dynamic disk.  

On the "test" server, the initial file was 13GB.  The compact operation took it down to 10GB.  But the conversion to fixed disk made it 83GB?

mikeshaverAuthor Commented:
On the test server, the size of the "disk" in the guest OS is 80gb.  So I'm assuming that making the disks "fixed" makes the .vhd the size of the actual "fixed" disk?  If so, doesn't that make my issue of getting the size of the .vhd smaller, "worse?"  

Basically, the .vhd in question (appears to be dynamic, is Exchange 2010) is 300GB.  Its taking forever to back it up as the image (so I can restore to a different Hyper V server if I need).  The data is only 80GB on this Exchange server, but obviously it will grow over time.  

If I make this disk into a "fixed" disk (I understand the benefits), I assume there is a way to set the size?  Perhaps I should set it to say 200gb...which gives me 120GB of growth, but reduces the size of the .vhd from 300 (and likely expanding) to 200gb?

Am I on the right path with the above?
Greg HejlPrincipal ConsultantCommented:
yes - you can set the size of the fixed disk

by Data disk I mean Not the OS VHD which should Always be Fixed.

you'll find when messing with OS vhd's it works best to detach them from the machine and attach to another vm as a data drive - manipulate then attach back to original machine.

OS VHD's behave a bit differently due to disk size being registered in OS

you are on the right path.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If you are complaining about the disk taking too much space on the host, converting to fixed just made that worse by making the amount os space occupied by the VHD to be equal to the size of the disk as seen by the VM. I use dynamic VHD for all of my OS and data drives because I can allocate 40 GB to a VHD for the OS and if it only needs 10 GB, then I am saving 30 GB for other stuff. It saves me from having to buy disk capacity that I may never actually use. The only real downside of dynamic VHD is that you need to make sure that you have enough physical capacity to meet the needs of growing dynamic VHD, but again if you use fixed disks you had to already deploy that physical capacity, so you are really no worse off as long you are monitoring.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.