A little while ago I published a number of posts discussing the process I used to move my virtual machines from using dynamically expanding virtual hard disks to using fixed-size virtual hard disks. There were some interesting questions / discussions in the comments – so I thought I would try to sum them up here:
- Why would I use dynamically expanding VHDs?
Dynamically expanding VHDs are easy and flexible. They are great for quick deployment, and allow you to not worry about how much space is currently available. When I am doing test work with Hyper-V (and definitely when I am setting up demos with Hyper-V) I almost always use dynamically VHDs.
- Why would I use fixed VHDs?
The two main advantages of using fixed-size virtual hard disk performance and not having to worry about running out of space unexpectedly. Of course, the downside is that you have to allocate all of that disk space ahead of time, and potentially waste space if you allocate too much.
- When do you (Ben) use dynamically expanding VHDs and when do you use fixed-size VHDs?
As a general rule of thumb: If I am going to be sitting at the console of the computer when virtual machines are running, I use dynamically expanding virtual hard disks – but if I expect virtual machines to run for weeks on end without me having anything to do with them, I use fixed-size virtual hard disks.
For me – I have never had a system where disk performance was so critical that I needed to use fixed-size virtual hard disks, which means it all comes down to space management.
- How do you expand a fixed VHD?
This was a question that came up a couple of times. An obvious step to take when using fixed-size virtual hard disks is to try and make the virtual hard disks as small as possible, so you do not waste too much space. But what do you do if a virtual machine needs more than you originally allocate to it? Thankfully – it is not too hard to increase the size of a virtual hard disk for a virtual machine. Here are the steps you need to follow to do this:
- Shut down the virtual machine
- Open the virtual machine settings and find the virtual hard disk that you want to expand
- Click the Edit button for the virtual hard disk
- Select Expand and click Next
- Enter the new size for the virtual hard disk and click Finish
- Note – expanding may take a while, depending on how much space you are adding to the disk.
- Close the virtual machine settings and boot the virtual machine
- Now you need to increase the partition inside the virtual machine – for Windows Server 2008 R2 / Windows 7 you need to:
- Login to the virtual machine with an administrative account
- Open the start menu, right click on Computer and select Manage
- Find the entry for Disk Management
- Locate the partition that you want to expand – right click on it and select Extend Volume…
- Hit Next twice and click Finish
- What about limiting dynamic VHDs?
A couple of people suggested keeping with dynamically expanding virtual hard disks – but just being careful to not go crazy with maximum sizes for the disks. One person also suggested creating large dynamically expanding virtual hard disks – but only creating small partitions inside of them (and expanding the partition while the virtual machine was running if more space was needed). Both of these options seem reasonable – but personally I would not trust myself to calculate my expected disk usage correctly – so I will be sticking with fixed-size virtual hard disks on my production systems.