Windows 10: Hyper-V - Optimizing Virtual Machines

Discus and support Hyper-V - Optimizing Virtual Machines in Windows 10 Tutorials to solve the problem; How to: Hyper-V - Optimizing Virtual Machines Running Windows on a virtual machine can naturally never be as fast as same version of Windows on same... Discussion in 'Windows 10 Tutorials' started by Brink, Jul 20, 2018.

  1. Brink Win User

    Hyper-V - Optimizing Virtual Machines

    How to: Hyper-V - Optimizing Virtual Machines

    Running Windows on a virtual machine can naturally never be as fast as same version of Windows on same computer running on physical hardware. However, by tweaking virtual machine settings, you can greatly impact the speed and functionality of a virtual machine.

    In this tutorial, you'll find some simple tips to make your virtual machines to run better.

    Contents [/i] Click links to jump to any part

    [table][tr][td]Part One:[/td] [td]VHD storage location[/td] [/tr] [tr][td]Part Two:[/td] [td]Virtual RAM (vRAM)[/td] [/tr] [tr][td]Part Three:[/td] [td]Virtual Processors (vCPU)[/td] [/tr] [tr][td]Part Four:[/td] [td]Using Checkpoints[/td] [/tr] [tr][td]Part Five:[/td] [td]Export & Import Virtual Machines [/td] [/tr] [tr][td]Part Six:[/td] [td]Ideal VM settings[/td] [/tr] [tr][td]Part Seven:[/td] [td]Additional tips & information[/td] [/tr] [/table]

    Part One [/i] VHD storage location
    1.1 It is recommended to store virtual hard disks on an SSD, if possible.

    1.2 Storing virtual hard disks on an HDD affects the time required to install Windows on VM, boot time, and restart time. It also affects the time required to install software, and large Windows updates like full feature upgrades.

    Using my laptop (HP ProBook 470 G5) as an example, when the VHD is on SSD, installing Windows 10 takes about 7 minutes from start to desktop, whereas VHD on HDD requires over 20 minutes. Booting a VM from SSD takes about 40 seconds, restart about a minute. Booting VM from HDD, it takes almost two minutes to boot, over three minutes to restart.

    However, don't worry if you do not have an SSD. In normal use, virtual machines with VHD on an HDD work nicely, when it has been tweaked with optimal settings.

    1.3 Using Differencing Disks (tutorial) is recommended if your SSD is relatively small. Differencing disks means that a VM is stored on two different virtual hard disks, a so called Parent Disk containing the base Windows installation, and a Child Disk which contains all user profiles and data, settings, customizations and software.

    VM boots from Parent Disk where the base Windows is installed, which then passes the control to the Child Disk.

    1.4 Storing the Parent Disk on an SSD, and Child Disk on HDD is a good compromise. You save storage space on SSD, yet get faster VM than if only HDD was used to store virtual hard disk(s). In addition you can save a lot of storage space used by your virtual machines in general; one Parent Disk can be used for unlimited number of Child Disks.

    An example. Let's say you have the Windows 10 version 1903 installed on a Parent Disk. You'd like to use four virtual machines for all available Insider Ring builds, one for Release Preview, one for Slow, one for Fast and one for Skip Ahead.

    Version 1903 on Parent Disk takes about 11 GB. Creating four new virtual machines with Child Disks using this Parent Disk, this 11 GB is saved on each VM. You can then opt one VM in for Release Preview, one for Slow, one for Fast, and one for Skip Ahead.

    If all four virtual machines were using a normal VHD, they would all have over 11 GB virtual hard disks, a total of about 45 GB before any software would be installed. But, using a Child Disk, each VM requires only less than 2 GB VHD, because the base Windows installation on Parent Disk is used instead of complete Windows on Child Disks.

    In this example, you saved about 33 GB of storage space (4*11GB = 44 GB - Parent's 11GB = 33 GB).

    If you have an SSD for parent disks, and a fast USB3 external HDD, you can store your child didks on that external HDD. Hyper-V has no issues in running virtual machines from an external disk.

    Part Two [/i] Virtual RAM (vRAM)
    2.1 By default, Hyper-V virtual machines are set to use 1 GB starting vRAM and dynamic memory. Dynamic memory means that a VM only uses as much vRAM as is currently required. A VM with default settings starts with 1 GB vRAM, then assigns it more vRAM when needed, and reduces the amount of vRAM when additional memory is no longer required.

    Dynamic memory can fluctuate between set minimum (default is 512 MB) and maximum (default 1048576 MB / 1 TB) values. Both min and max vRAM can be set as user prefers.

    2.2 Hyper-V monitors the memory demand for each VM that is using dynamic memory. The demand depends on what's happening on VM; if you run Word and Excel at the same time, the demand increases and Hyper-V assigns more vRAM to VM. This is theoretically very good, but it would require all software and VM actions to report the demand in real time.

    Unfortunately, this is not the case. For instance, running a Windows feature upgrade should tell Hyper-V that for it to work, VM needs more RAM, in case VM has less than 2 GB available at the moment the upgrade is started. But, Windows Update does not report correct demand, therefore user might see this:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    (Click screenshots to enlarge.)

    In case of Windows feature upgrade, it's not as much it not demanding enough dynamic vRAM for the VM, than the fact that the demand is sent too late. The actual demand works a bit delayed, VM has not had time to adjust for greater memory demand when it' needed.

    A simple workaround is to shut down the VM, disable dynamic memory, and assign enough static vRAM to get VM upgraded.

    A bit more complicated workaround is to launch a bunch of software to increase the demand, and when the demand has increased VM vRAM (shown in Hyper-V Manager under column Assigend Memory) over required amount, close all open software and run upgrade again.

    2.3 You can also increase the available dynamic vRAM by changing the Memory Buffer size in VM settings. By default, a dynamic vRAM buffer is 20%. It means that VM is always assigned 20% more vRAM than it currently demands; if memory demand is 1 GB, VM is assigned 1.2 GB:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    2.4 A practical way to follow memory demand in real time is to use Windows Admin Center (WAC, see tutorial).

    Managing virtual machines in WAC shows you real time memory demand and assigned vRAM for each VM. In screenshot, a Windows 10 Insider VM with default settings has been booted to desktop and left idle. Its current memory demand is 707 MB, so it has been assigned that plus the default 20% buffer, 852 MB:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    2.5 Memory weight, on same settings page than memory buffer (see step 2.3), means which VM has priority to access host RAM and its own vRAM. I recommend leaving it as by default, each VM memory weight being in the middle at 50%.

    2.6 Dynamic memory with low minimum vRAM value makes it possible to run more virtual machines simultaneously. However, as it can make virtual machines quite slow, I prefer static vRAM on my virtual machines, never using dynamic memory.

    I assign 3 or 4 GB static vRAM for each Windows 10 VM, 2 or 3 GB for Windows 8.1 VM, 2 GB for Windows 7 and 1 GB for any Linux VM. Windows 10 x64 runs really nicely with 3 GB, Windows 7 & 8.1 with 2 GB.

    To calculate how many virtual machines I can run at the same time, I use a simple formula. I have noticed, that Windows 10 on this laptop runs really nicely when it has 5 GB RAM available. I'll add a 2 GB "buffer", which leaves me 9 GB to use on virtual machines of the 16 GB total RAM.

    For me, it means that I can run three virtual machines with 3 GB vRAM at the same time, or two using 4 GB. I quite often have one VM running Windows 7 (2 GB), one 8.1 (3 GB), and one Windows 10 (4 GB). All virtual machines running smoothly, host having enough RAM for its needs.

    2.7 It is of course up to you if you decide to use dynamic memory. My recommendation is at least to disable it when installing Windows, or when doing a feature upgrade.

    Part Three [/i] Virtual Processors (vCPU)
    For information about Hyperthreading and logical processors, see these articles:
    - About Hyper-V Virtual Processor Limitations
    - Hyper-threading - Wikipedia

    3.1 Maximum number of virtual processors you can assign to a single VM is the number of logical processors on your host. Open Task Manager, select Performance tab, and select CPU to see how many logical processors you have available:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    That is the maximum number of virtual processors you can assign to a VM.

    3.2 If trying to assign more vCPUs to a VM, Hyper-V shows a warning:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    Virtual machine will not start if it detects too many virtual processors.

    3.3 Everything in Windows is run and executed in threads. Each thread can handle one instruction at any given time, the system then decides which thread is executed next, You can read more about this here: Virtualization : Processor, Core, Logical Processor, Virtual Processor : What does this mean? | buildwindows

    A VM can only use an assigned vCPU, basically a logical processor or thread on host, when that thread is idle, not used by host. What this means is that a VM can be totally unable to work if it and other virtual machines running at the same time are demanding to use all available threads; as there are no idle threads on host, a VM suspends its vCPU until matching thread on host becomes available.

    3.4 A good "rule of thumb" is to use 2 to 1 ratio, assign each VM 1 vCPU for each 2 host logical processors. In my example case, having 8 logical processors, I usually assign 4 vCPU per VM. This applies to all Linux and post-XP virtual machines; those still wanting to run Windows XP or Vista virtual machines, remember that they do not accept more than 2 vCPUs.

    For some heavy duty Windows virtual machines used to image customization and other deployment tasks, I assign the maximum, 8 vCPU.

    3.5 Monitoring the virtual processors, you can see a clear difference when amount of vCPUs is increased.

    First, a VM with 4 GB and 2 vCPU, running a feature upgrade:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    Next, the same VM but now with 8 vCPU, running the same upgrade task:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    3.6 The recommended maximum number of vCPUs at use at the same time is 8 times the number of host logical cores. In my case now, having 8 logical processors, it would mean that my running virtual machines should not exceed 8*8=64 vCPUs at any given time.

    However, this is just a theoretical limit, more a recommendation than rule. As long as you have enough RAM and processing power on your host, you can run almost unlimited number of virtual machines at the same time.

    Part Four [/i] Using Checkpoints
    4.1 A checkpoint in Hyper-V stores the current state of a VM. When checkpoint is applied, Windows on VM is restored as it was at the moment of creating the checkpoint. This is very practical when testing software or Windows features; changes can be discarded simply by applying an earlier checkpoint. Full Ten Forums Hyper-V Checkpoint tutorial: Create and Use Hyper-V Checkpoints in Windows 10

    4.2 Hyper-V uses two different types of checkpoints, Standard and Production. A Standard Checkpoint is basically the same as a Windows 10 restore point; when created, it captures the current state of Windows 10, but not that of open applications and processes.

    My recommendation is to always use Production Checkpoints. A Production Checkpoint captures current state of Windows, and all software and processes running at the time when checkpoint is created.

    An example: if you are in the middle of copying a large file from network to VM, and you create a Production Checkpoint when file copy progress is at 44%, when you later apply that checkpoint, the file copy continues from that 44%. The same with an open not saved Word document; when checkpoint is applied, the document will be open on VM desktop.

    4.2 By default, Hyper-V uses / creates automatic checkpoints. I strongly recommend to disable this feature before running a new VM first time.

    In all time I have used Hyper-V, I have only found one scenario where automatic checkpoints can be useful. I do a lot of Windows image customization and deployment tests; creating a new, clean and empty VM with automatic checkpoint lets me to restore the virgin state of that VM when deployment does not work, and I must repair the image. Other than that, I think automatic checkpoints in Hyper-V is its most unnecessary feature.

    4.3 My recommendation for checkpoint settings. You should check this everytime before starting a new VM first time:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    Part Five [/i] Export & Import Virtual Machines
    5.1 Especially if you have activated your Windows virtual machines, it is important to preserve them and their activation status by exporting them.

    5.2 To export a a VM to an external disk, see this tutorial: Export Hyper-V Virtual Machine in Windows 10

    After exporting VM, it can be deleted from Hyper-V Manager if not currently needed.

    5.3 When the VM is again needed, import it back to Hyper-V: Import Hyper-V Virtual Machine in Windows 10

    A hard disk on a physical machine, or VHD on a virtual machine on an activated Windows 10 system can be replaced without losing the machine's activation status (digital license).

    What I always do when I have activated a Windows 10 virtual machine is to remove its VHD, and export it without any disk. I now have an activated Windows 10 VM with no disk. When I want, I can just import the VM, attach a new VHD to it, and install the same edition of Windows 10 it had when activated. New installation will be automatically activated, based on the existing digital license.

    I even have have a few exported virtual machines on a safe storage which have digital licenses for Home, Pro, Education and Enterprise editions; when imported back to Hyper-V, I can install any of the four editions, all of them automatically activated, or install all four editions on VM in multi boot, all activated.

    Part Six [/i] Ideal VM settings
    6.1 The ideal settings for a VM is a subjective thing, based on multiple factors. The recommendations in next step are based on following factors:
    • Windows 10 x64 host
    • 16 GB RAM
    • 8 logical processors
    • An SSD and an HDD
    • Guest (VM) OS Windows 10 x64
    6.2 For those specs, my recommended settings for a VM, which I have found to be quite good are as follows:
    • 4 GB vRAM
    • 4 vCPU
    • Disable Secure Boot
    • Production Checkpoints
    • Disable Automatic Checkpoints
    • Install on Differenicing disks, Parent Disk on SSD
    6.3 It is extremely important to let host have enough resources to run smoothly. Never run virtual machines with less than 2 GB available for host. That is the absolute minimum, I recommend always having at least 4 GB for host.

    What this means is that if you only have 4 GB of RAM, never assign more than 2 GB for a VM, and from 8 GB RAM, never more than 4 GB.

    Part Seven [/i] Additional tips & information
    7.1 A very nice feature in Hyper-V is the possibility to select virtual machine's Stop Action and Start Action.

    7.2 If you have a virtual machine which is normally always on and running, you can select to save its state when host is turned off, shut down or restarted:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    This is the default action. You can also select to automatically turn VM off, or shut it down, when host is turned off / shut down / restarted.

    7.3 Depending on your selected Stop Action, the VM will be automatically started at next boot (default action) if you so wish:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    Accepting defaults in both Stop and Start Action, the VM which was running when you shut down the host, will be automatically restored to its last state when host is rebooted.

    7.4 To boot a VM faster, save its current state by clicking the Save button:

    Hyper-V - Optimizing Virtual Machines [​IMG]

    This saves the current state of VM. When started next time, instead of clean boot, the VM is restored fast to its saved state.
    That's it, geeks. Happy virtualization!


    Related Tutorials

    Brink, Jul 20, 2018
  2. SarahKong Win User

    Hyper-V Virtual Machine not recognised

    The folder where your VM is do you see a .vhd file?

    Here is a great article step by step on how to import VM into hyper-v.
    SarahKong, Oct 27, 2019
  3. Andre Da Costa, Oct 27, 2019
  4. Hyper-V - Optimizing Virtual Machines

    Mark St..., Oct 27, 2019
  5. Rex99ny Win User
    Where is the Hyper V Manager, How to I start it ?

    I am trying to setup an XP virtual Machine on Windows 10 Pro.

    I followed the steps in Neil Peterson article of 5/9/2016.

    System Requirements - done - ok

    Install Hyper-V - done - ok

    Create a Virtual Switch - skip

    Create a Virtual Machine

    Create a Virtual Machine with Hyper-V Manager

    These steps walk through how to manually create a virtual machine and deploy an operating system to this virtual machine.

    • In Hyper-V Manager, click Action > New >
      Virtual Machine
      to bring up the New

    Uhhhhhhhhh - this step obviously implies one knows

    1) Where the Hyper-V Manager is

    2) How to start the Hyper-V Manager

    Isn't that odd ?
    Rex99ny, Oct 27, 2019
  6. SarahKong Win User
    Hyper-V Virtual Machine not recognised

    Ok that's why you can't add it... Virtual Machines are stored in a .vhd or .vhdx file. The xml file is used for the VMs but you also have to have a valid vhd

    Are you trying to import one you used previously or just trying to create a new VM?
    SarahKong, Oct 27, 2019

Hyper-V - Optimizing Virtual Machines

  1. Hyper-V - Optimizing Virtual Machines - Similar Threads - Hyper Optimizing Virtual

  2. Issues with Hyper-V Virtual Machines

    in Windows 10 Network and Sharing
    Issues with Hyper-V Virtual Machines: Hi all, I'm running Ubuntu 19.04 in a Hyper-V Virtual Machine. It's configured to use Hyper-V's "Default Switch" network adapter, but for some reason, the VM doesn't seem to get internet access. My computer is connected to the Internet (both through Wi-Fi and Ethernet). I've...
  3. Hyper V- Virtual Machine Error

    in Windows 10 Updates and Activation
    Hyper V- Virtual Machine Error: While starting the Vistual Machine i am facing the below error shown in Event Viewer. Plz Help me out to resolve this problem. License Activation (slui.exe) failed with the following error code: hr=0x8007232B Command-line arguments:...
  4. Hyper V not connecting to virtual machine

    in Windows 10 BSOD Crashes and Debugging
    Hyper V not connecting to virtual machine: Suddenly, Hyper V would not connect to any Virtual Machine using the Virtual Machine Connection. I trying creating new VMs and nothing worked. I am using Windows 10 Education....
  5. Hyper-V Nested Virtualization: Run virtual machines on virtual machine

    in Windows 10 Tutorials
    Hyper-V Nested Virtualization: Run virtual machines on virtual machine: How to: Hyper-V Nested Virtualization: Run virtual machines on virtual machine [img] Information Nested Virtualization means that user can enable Hyper-V on existing virtual machines, and run virtual machines and Windows Sandbox on them. To make Nested Virtualization...
  6. Backing up Hyper-V Virtual Machines

    in Windows 10 Virtualization
    Backing up Hyper-V Virtual Machines: Hi, I was wondering if all I really need to do to backup activated virtual machines but not associated virtual hard drives is just to copy the virtual hard drive folder to another drive (or even one drive) . All I am really interested is in saving the machines which have...
  7. Import Hyper-V Virtual Machine in Windows 10

    in Windows 10 Tutorials
    Import Hyper-V Virtual Machine in Windows 10: How to: Import Hyper-V Virtual Machine in Windows 10 How to Import Hyper-V Virtual Machines Hyper-V enables running virtualized computer systems on top of a physical host. These virtualized systems (aka: guests) can be used and managed just as if they were physical...
  8. Hyper-V - Create Custom Virtual Machine Gallery

    in Windows 10 Tutorials
    Hyper-V - Create Custom Virtual Machine Gallery: How to: Hyper-V - Create Custom Virtual Machine Gallery [img] Information Quick Create is a feature in Hyper-V allowing users to setup new virtual machines with a few mouse clicks. At the moment, Quick Create offers users a quick setup of Windows 10 Developer Environment,...
  9. Export Hyper-V Virtual Machine in Windows 10

    in Windows 10 Tutorials
    Export Hyper-V Virtual Machine in Windows 10: How to: Export Hyper-V Virtual Machine in Windows 10 How to Export Hyper-V Virtual Machines in Windows 10 Hyper-V enables running virtualized computer systems on top of a physical host. These virtualized systems (aka: guests) can be used and managed just as if they were...
  10. Create Shortcut of Hyper-V Virtual Machine in Windows

    in Windows 10 Tutorials
    Create Shortcut of Hyper-V Virtual Machine in Windows: How to: Create Shortcut of Hyper-V Virtual Machine in Windows How to Create Shortcut of Hyper-V Virtual Machine in Windows 8 and 10 [img] Note There's nothing wrong in running the Hyper-V Manager and launch your virtual machines from there. However, creating a...