Posey's Tips & Tricks

What Happens When Hyper-V Runs Out of Disk Space?

It can happen. Here's a couple of options when you've hit the ceiling.

I have been using Hyper-V since it was first released with Windows Server 2008. As far as I can remember, during that time I have never run into a situation in which a virtual machine completely ran out of disk space -- until yesterday. That being the case, I wanted to take the opportunity to talk about what happens when Hyper-V exhausts its available disk space and what your options are when this happens.

When it comes to discussing what happens when Hyper-V runs out of disk space, the first thing that must be considered is the type of virtual disk that the virtual machine is using. Hyper-V allows you to create two main types of virtual disks: fixed length and dynamically expanding.

A fixed length virtual hard disk is a virtual hard disk in which all of the physical disk space is allocated at the time that the virtual hard disk is created. If for example, you were to create a 100 GB fixed length virtual hard disk, then 100 GB of physical disk space would be immediately reserved for that disk.

A dynamically expanding virtual disk works differently. Rather than claiming all of the physical disk space at the time when the virtual disk is created, the virtual disk initially claims only a very small amount of storage space. It then consumes additional storage space on an as needed basis until the virtual disk's maximum allocated capacity is eventually reached.

Now that I have talked about the two main types of virtual disks, I want to talk about the various ways in which it is possible for a virtual machine to run out of disk space.

The most obvious way in which storage space can be depleted is simply by filling up the virtual disk. If for example, the virtual disk is 100 GB in size and you store 100 GB of data on that virtual disk, then the virtual disk will be full. It doesn't matter if the virtual disk is of a fixed length or is dynamically expanding. Every virtual disk is of a particular size, just as physical disks are of a certain size.

The other way that virtual machines can run out of disk space is that their physical disk space becomes depleted. This problem mostly occurs with dynamically expanding virtual disks, but under the right circumstances it can also cause problems for virtual machines that are using fixed length virtual disks.

The reason why this problem happens is because even if the virtual disk has not yet reached its full capacity, the physical storage space has been fully consumed, meaning that there is no way for the virtual disk to expand to store more data. There are a couple of different reasons why this happens.

One reason has to do with over provisioning. Let's suppose for a moment that you have a physical disk that has 4 TB of storage space. There is nothing stopping you from creating a 5 TB dynamically expanding virtual disk on top of that 4 TB drive. Once the virtual disk contains 4 TB of data however, the physical disk will be full, even though the virtual disk provides the illusion of having more free space available. This is what happened to me.

The other reason why physical disk space might fill up is because often times a virtual disk does not have sole ownership of physical disk space. The physical disk space might be shared for example, by multiple virtual disks. When any one of those virtual disks grows then it reduces the amount of physical disk space that is available for the other virtual hard disks to use.

As previously noted, my disk space shortage happened as a result of over provisioning. I use removable hard disks for air gapped backups. I had been backing up a 20 TB virtual disk to an 8 TB physical disk. In the past, it didn't really matter because I had not yet accumulated 8 TB of data on that volume. Even so, you can see in Figure 1 that my 8 TB disk (L:) did eventually fill up.

[Click on image for larger view.] Figure 1. My physical disk is completely full.

In case you are wondering, it is possible to mount a virtual hard disk, even if the underlying physical disk is completely full. Windows simply treats the virtual disk as read only. If you look at Figure 2, you can see that I have mounted the virtual disk as N:. Windows still thinks that there are several terabytes worth of free space available on the virtual disk, even though the underlying physical disk is full.

[Click on image for larger view.] Figure 2. I have mounted my virtual disk as N:.

In my situation, the fix for this problem was simple. I just redirected my backups to a larger physical disk. But suppose that wasn't an option... What else could be done?

The best option in those types of situations is to try to shrink the virtual disk. Although a dynamically expanding virtual hard disk grows as you add data, it does not shrink as you remove data. As such, if you have deleted data from the virtual disk, then there may be space that can be reclaimed. You can use the Hyper-V Manager's Virtual Hard Disk Wizard to compact the disk. Keep in mind that when you compact a virtual hard disk, Hyper-V makes a second copy of the virtual disk, so you will need to have enough disk space available to temporarily accommodate that secondary copy.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube