In my travels, I have noticed that the default storage paths used by Hyper-V can cause some confusion. To be honest, I don’t like how Hyper-V stores virtual machines by default; System Center Virtual Machine Manager (SCVMM) handles the folder structure in a much more attractive fashion. In this post, I will explain where Hyper-V stores virtual machine files by default, and how you can manipulate those settings to get a better configuration.
Hyper-V Storage Path Settings
There are two default storage paths defined in each host’s Hyper-V settings. You can find and edit these paths by opening Hyper-V Manager, connecting to and selecting your host, and choosing Hyper-V Settings from Actions. Here you will find two settings.
Virtual Hard Disks is the default storage location for any new virtual hard disk that you create. The default location is C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks. Checkpoints (AVHD or AVHDX files) will also be stored in this location.
Virtual Machines is where the XML file (named after the GUID of the virtual machine) for a virtual machine configuration will be stored. The default location for those XML files is C:\ProgramData\Microsoft\Windows\Hyper-V. BIN files (to reserve space for virtual machines that will enter a saved state when a host shuts down) and VSV files (a saved state) are stored in a subfolder that is named after the GUID of the virtual machine.
When you think about it, both of those locations are pretty dumb. On a nonclustered host, you should never store virtual machines on the system drive. And who thinks it’s a good idea to bury virtual machine and virtual hard disks in program and profile folders?
Microsoft cannot predict what kind of storage you will supply and where it will be located so it is up to us to supply better paths. In the cause of a non-clustered host with internal storage I will have a second volume (RAID 10 array) labelled as the D: drive. I will create a folder there called Virtual Machines. I then edit the Hyper-V settings of the host, and reconfigure both the Virtual Hard Disks and the Virtual Machines folders to point to D:\Virtual Machines.
It’s a bit trickier when you are dealing with more complex installations. I could say that you should use SCVMM in those scenarios and it will do a good job and using the correct storage for you. But not everyone can afford System Center. So in that case, maybe you should reconfigure the default paths to the location of your preferred CSV or SMB 3.0 volume.
Virtual Machine File Locations
Once in a while I will visit a site and find that all of their virtual machine XML and virtual hard disk files are in a single folder and a rather untidy flat file structure. It takes some time to figure out what XML file is associate with what virtual machine, and the file is named after the GUID of the virtual machine. I would not classify myself as a clean freak, but I cannot stand this layout. And it really annoys me that Hyper-V steers you into this direction.
The below screenshot is taken from the New Virtual Machine Wizard in Hyper-V Manager. An administrator will enter the name of the new virtual machine. If they do not check the Store The Virtual Machine in a Different Location box, then they get a rather untidy collection of files.
The next screenshot shows you what the Virtual Machines folder would look like. Each virtual hard disk was created using the wizard, so they are named after the attached virtual machine by default.
The contents of the Virtual Machine subfolder is a mess, as is the contents of the Snapshots subfolder. You will need to know the GUIDs of each virtual machine to know what file is owned by what virtual machine.
You can prevent this mess if you check the Store The Virtual Machine in a Different Location box in the New Virtual Machine Wizard. All you have to do is check that box, and the wizard will create a subfolder, named after the virtual machine, to store all of that virtual machines files. If you create 10 virtual machines, then you get 10 subfolders in the Virtual Machine path that is configured in Hyper-V Settings.
The virtual machine folder will contain two subfolders by default. Virtual Machines is where the XML file is stored. Virtual Hard Disks is where the virtual machine’s VHD or VHDX files are kept. And Snapshots is where the checkpoint (formerly known in Hyper-V Manager as a snapshot) is kept. The BIN and VSV files continue to be kept in a subfolder of Virtual Machines named after the GUID of the virtual machine.
So my advice is simple:
- Reconfigure the default storage paths in Hyper-V Manager.
- Always check the box to Store The Virtual Machine in a Different Location in the New Virtual Machine Wizard.
Tagged with storage paths