Hyper-V VM BIN file and AutomaticStopAction

What is a Hyper-V VM BIN file?

The .bin file is a Hyper-V VM associated file located inside the GUID folder of a VM.

If a VM’s AutomaticStopAction is set to: Save the virtual machine state then Hyper-V will reserve disk space equal to the amount of memory used by the virtual machine when it is running so that memory can be written to disk when the physical computer shuts down. If the VM is powered off, there will be no BIN file present, even if the VM is set to save.

Hyper-V Automatic Stop Action Settings
Hyper-V Automatic Stop Action Settings

How does the AutomaticStopAction setting affect available disk space?

The file acts as reserve point on the disk for the memory of a VM and can be located inside the GUID folder mentioned above.

The example below shows the VMs GUID location for a VM that was created with 8GB of RAM.  Because the VM’s AutomaticStopAction is set to save the virtual machine state approximately 8GB of hard drive space is reserved.

Hyper-V .bin file for a VM with 8GB of RAM
Hyper-V .bin file

This is something that needs to be taken into account when provisioning a large numbers of VMs that have a high amount of RAM allocated.  For example, 50 VMs with 16GB of RAM would require an additional 800GB of storage space (50 VMs * 16GB .bin file = 800GB on disk). This is often overlooked by admins who can quickly find themselves running out of space due to this setting.  If you don’t wish to suspend your VMs when the host shuts down, you can set the AutomaticStopAction to Shutdown (recommended) or Turnoff (not sure why you would want this) which eliminates the .bin file, and can free up significant amounts of disk space.

How much hard disk space are my .bin files taking up?

Each VM that has its AutomaticStopAction set to save the virtual machine state is taking up that VMs RAM amount in disk space (when on).

The PowerShell script below will get all VMs on the host, identify those that are set to save on shutdown, and determine how much storage space is being utilized:

$vms = Get-VM
$vmMemory = 0
foreach($vm in $vms){
    if($vm.AutomaticStopAction -eq "Save"){
        $vmMemory += [math]::round($vm.MemoryAssigned / 1GB, 0)
    }
}
Write-Host "VM .bin files are reserving a total of: $vmMemory GB of Hard Drive Space" `
    -ForegroundColor Cyan

What is the most appropriate setting for AutomaticStopAction?

For standalone Hyper-V servers that’s really up to you.  If the host needs to go down for maintenance, or patching, you may find it useful to momentarily suspend the VMs until the host comes back up.  For me personally though, the associated disk cost isn’t worth it.  If the AutomaticStartAction is set to: StartIfRunning, then the VMs will be shutdown during a host shutdown, and will then be turned back on when the host comes back up.  I’ve also encountered several applications and services (Domain controllers being a prime example) that don’t like being suspended and operate better with a clean shutdown.  My .02 – recoup the disk space and have your VMs shutdown in the event of a host shutdown.

For Hyper-V clusters, there is really no reason to ever have the AutomaticStopAction set to save.  The VMs will simply be Live Migrated if the host is shut down.

I’d like to change my VMs AutomaticStopAction to shutdown – but there are so many!

The bad news: this can only be changed if the VM is turned off, so you are going to encounter some down time.

The good news: the following script will make that downtime very short by looping through all your VMs, finding those with AutomaticStopAction set to save, shutting them down, changing AutomaticStopAction to shutdown, and then starting the VMs back up!

#warn user
Write-Host "This will SHUT-DOWN all VMs that are set to AutomaticStopAction 'Save',"`
    "change to 'Shutdown', and the start the VMs back up" `
    -ForegroundColor Red -BackgroundColor Black
#ask user if they are ABSOLUTELY sure they want to do this
while ("Y", "N", "y", "n" -notcontains $choice) {
    $choice = Read-Host "Are you ABSOLUTELY sure you want to proceed? (Y/N)"
}
$vms = Get-VM
foreach($vm in $vms){
    if($vm.AutomaticStopAction -eq "Save"){
        Stop-VM -Name $vm.Name -ErrorAction SilentlyContinue | Out-Null
        Set-VM -Name $vm.Name -AutomaticStopAction ShutDown
        Start-VM -Name $vm.Name
    }
}

Additional Reading:

Niklas Akerlund’s Hyper-V VM´s BIN files, to be or not to be in clusters

Technet Blog: What’s the difference between High-availability and Live Migration?

2 Comments

  1. I’ve seen a few of your videos on Youtube and I think you’re doing a great job.
    Is it possible you could share some thoughts on hardware?

    1] For example is it possible to to work with virtual machine mobility between virtual hosts?

    Lets say I wanted to be able to study Hyper-V clustering and Hyper-V replica.
    No matter how much money you spend on a server, when it comes to Server 2012 and R2, you can’t go hands-on with these virtualisation topics using only one computer.

    Do you know a way around this point?

    Secondly, could you list some budget set-ups which you think would work with Hyper V if you can’t do that, can you share your setup and give some advice how to run hyper v efficiently?

    Please state hardware requirements.

Leave a Reply

Your email address will not be published.


*