How to run a virtual machine on Windows 10?


Hyper-V is better known as a server virtualization technology; however, starting with Windows 8, it is also available on the client operating system. In Windows 10, we've made significant improvements to make Hyper-V a great solution for developers and IT professionals. Microsoft Hyper-V, codenamed Viridian, is a native (Type 1) hypervisor that, unlike VMware Workstation, VirtualBox, and other Type 2 hypervisors, runs directly on the hardware. It was first released in Windows Server 2008 and allows you to run virtual machines on x86-64 systems. Hyper-V allows developers to quickly overclock development virtual machines on Windows 10 with superior performance, but it is also used in several other development functions as a server technology, such as the Android emulator, Windows Subsystem for Linux 2 (WSL2), or containers Docker. In this article, we'll take a quick look at how Hyper-V on Windows 10 can help developers.

Quickly create a collection of virtual machines

First, let's start with one of the basic functions for creating virtual machines. Now you can not only create Hyper-V virtual machines by installing them using an ISO file; you can use Hyper-V Quick Create VM Gallery to quickly create a new Windows 10 development environment or even an Ubuntu virtual machine. The tool will boot a pre-configured Hyper-V virtual machine with Windows 10 and Visual Studio or Ubuntu 18.04 or 19.04 development environment. If you want, you can also create your own Quick Create virtual machine images and even share them with other developers.

Windows Subsystem for Linux 2 (WSL 2)

With Windows Subsystem for Linux, Microsoft brings the Linux environment to Windows 10 desktop and lets you run the GNU/Linux environment—including most tools, utilities, and command-line applications—directly on Windows without modifications, without the overhead of full virtual machines. In the latest versions of Windows 10 Insider Preview, Microsoft released a preview of WSL 2. WSL 2 uses Hyper-V virtualization technology to isolate and virtualize WSL on the back end. This provides not only security benefits, but also huge productivity gains. You can learn more about Windows Subsystem for Linux 2 here.

Setting up VirtualBox

Due to the narrow focus of the program, an untrained user may have questions about how to create their own virtual machine. Next, in the instructions, we’ll look at how to correctly set the VirtualBox settings on Windows 10. Open the software and click on the “Create” button at the top of the working window.

The application creates a working emulation of a pure computer system. To run an operating system on it, you first need to find a working OS image and install it.

The virtual machine express setup window will appear. In the “Name” field you need to enter the name of the future machine, then indicate the path where the files will be stored. You must specify the type of OS that will be shipped in the future.

Below you need to select the OS version. Depending on the selected option, the program will build the necessary parameters to correctly emulate the work. In our case, Windows 7 was selected.

You need to select the size of the allocated RAM for the virtual machine. Depending on the goals and the chosen system, you will need a different amount of RAM. The only limitation is the amount of RAM installed on the computer itself. Click “Next”.

For correct operation, you must allocate space on your hard drive. The program creates a virtual disk, similar in principle to partitioning into local disks. Create a new virtual disk.

Once setup is complete, you can find the virtual machine in the list on the left side of the application. Click on the icon that says “Run” to activate the emulation.

@how-to-install.rf

Enhanced session mode for sharing devices with your virtual machine

One of the difficult parts in the past was the interaction between the virtual machine and the host machine. With the addition of Enhanced Session Mode, Microsoft has made it easier to copy and paste files between them, and you can now share devices. Including:

  • Makes virtual machines resizable and high DPI
  • Improves virtual machine integration
  • Allows device sharing

Enhanced Session Mode is enabled by default in Windows 10 Hyper-V, in Windows Server you need to enable this feature in Hyper-V settings. If you're creating your own Linux virtual machine, make sure you install the latest virtualization drivers.

Standard virtual machine

Previously, the use of a hypervisor was limited to use only in server operating systems. The virtual machine is called Hyper-V because it is based on a hypervisor that supports virtualization for 64-bit operating systems. This technology allows you to generate a virtual machine for installing almost any operating system into it.

Hyper-V is intended only for 64-bit versions of Windows 8, 10 Pro and Enterprise, and for server operating systems. The user of these versions no longer needs to install additional virtualization programs on the PC, such as VirtualBox .

It is worth noting that the hypervisor was originally created only for server operating systems, so the capabilities of Hyper-V in Windows 10 are slightly limited:

  • Sound cards are not supported;
  • you cannot directly copy and paste files from a virtual OS to a real one and vice versa;
  • There is no ability to record CD/DVD.

You should know that if your computer is quite weak, then you should not even install this VM, since it requires quite a lot of memory for optimal operation. When using a virtual OS, you should not use resource-intensive applications in order to avoid slowing down your computer.

Checkpoints

A huge benefit of virtualization is the ability to easily save the state of a virtual machine, allowing you to go back or forward at a specific point in time.
In Hyper-V, this feature is called a virtual machine checkpoint, and was previously known as a virtual machine snapshot. Hyper-V knows the types of checkpoints:

  • Standard checkpoints: Takes a snapshot of the state of the virtual machine and the virtual machine's memory at the time the checkpoint is run.
  • Production checkpoints: Uses Volume Shadow Copy Service or Freeze File System on a Linux virtual machine to create a data-consistent backup of the virtual machine. A snapshot of the virtual machine's memory state is not created.

The checkpoint type can be set by the virtual machine. Both types of checkpoints have different advantages and disadvantages. In recent versions of Hyper-V, production checkpoints are selected by default. However, you can easily change this using Hyper-V Manager settings or PowerShell. On my Windows 10 client machine I prefer to use standard checkpoints as it also preserves the virtual machine's memory state, however on systems with production servers I highly recommend using production checkpoints and even then you should be careful.

What is it for

First, a little terminology. The operating system you are currently working on and reading this text is called the host. The OS installed and running within the host system is called a guest OS. Installing “ex-pi” on Virtualbox can serve different purposes. Even if your working system is Windows XP, a guest “copy” can also come in handy. Here are some popular uses for this feature:

  • Installing and launching Windows programs in a different environment (Ubuntu, Debian, etc.).
  • Using old applications and games that do not work on new systems (7, 8.1 or 10).
  • Testing potentially dangerous applications (the guest OS is isolated from the host system unless shared folders are created).

Here are at least three reasons why installing Windows XP in a virtual machine is not a fool's errand. In the end, you can simply practice for the sake of self-education. Virtualbox is cross-platform and runs on most operating systems. The only rule for its correct operation is to have a good supply of system resources. That is, to run Windows XP as a guest system, there must be at least 500 MB of unused RAM and a more or less unloaded processor.

NAT networks

One of the features that was very painful in the past was the network.
With the introduction of the NAT switching option in Hyper-V Virtual Switch, you can now easily connect all your virtual machines to the network your host is connected to. In Windows 10, you will get a default switch for connecting your virtual machines. If this is not enough or you want to use a virtual NAT switch on the Hyper-V server, you can use the following commands to create a virtual switch and NAT rule. You can learn more about Hyper-V NAT networks here.

Optimizing Windows for VirtualBox

Windows has many services and processes that run in the background and load the system, but they are not always needed, especially on a virtual machine, to improve Windows performance you can turn them all off. WMVare has released a tool specifically for this purpose, which you can download from this link.

You can already enable the shared clipboard through the menu “Devices” -> “Clipboard” -> “Bidirectional” , so you should not have problems copying the link.

After downloading, unpack the archive and run the resulting program:

In the program window you see all the available optimizations, most of them are enabled by default, so you just need to click the “Optimize” button in the lower left corner to start the optimization:

Once the optimization is complete, your Windows 10 in VirtualBox will run much faster and won't take up as much RAM. If this is not enough, then you can enable additional optimizations. If you are afraid that the utility will break something, then take a snapshot of the system state before moving on to optimization.

PowerShell Direct and HVC

If you want to interact with your virtual machine running Windows 10, you can use Hyper-V Manager and the console to interact directly with the operating system.
However, there are also two other options that allow you to manage and access virtual machines using the command line. PowerShell Direct allows you to create a PowerShell remoting session for a virtual machine using the VM bus, so no networking is required. The same goes for Linux virtual machines and the HVC tool, which allows you to create an SSH connection directly to the virtual machine. Both options also allow you to copy files to and from virtual machines. This is very useful if you have set up some automation and need to run some commands on the virtual machine.

Creating a Hyper-V virtual machine

Just as in the previous step, right-click on the name of your computer in the list on the left or click the “Action” menu item, select “Create” - “Virtual Machine”.

At the first stage, you will need to specify the name of the future virtual machine (at your discretion); you can also specify your own location of the virtual machine files on your computer instead of the default one.

The next step allows you to select the generation of the virtual machine (appeared in Windows 10, this step was not present in 8.1). Please read the descriptions of the two options carefully. Generation 2 is essentially a UEFI virtual machine. If you plan to experiment a lot with booting a virtual machine from different images and installing different operating systems, I recommend leaving the 1st generation (2nd generation virtual machines do not boot from all boot images, only UEFI).

The third step is to allocate RAM for the virtual machine. Use the size required for the OS you plan to install, or better yet, even more, taking into account that this memory will not be available in your main OS while the virtual machine is running. Oh, I usually shoot (I like predictability).

Next we have the network setup. All that is required is to specify the previously created virtual network adapter.

The virtual hard disk is mounted or created in the next step. Specify the desired location on the disk, the name of the virtual hard disk file, and also set the size that will be sufficient for your purposes.

After clicking “Next” you can set the installation options. For example, by selecting the “Install operating system from a bootable CD or DVD” option, you can specify the physical disk in the drive or the ISO image file with the distribution. In this case, when you turn it on for the first time, the virtual machine will boot from this drive and you can immediately install the system. You can also do this later.

That's all: you will be shown a summary of the virtual machine, and when you click the “Finish” button, it will be created and appear in the list of virtual machines in the Hyper-V manager.

Windows sandbox

Windows Sandbox is a new feature in Windows 10, released in version 1903. Windows Sandbox uses Hyper-V technology to provide Windows 10 Sandbox.
Sandboxing allows you to spin up an isolated, temporary desktop environment where you can run untrusted software. The sandbox is great for demos, development, testing, troubleshooting, or working with malware. If you close the sandbox, the entire software with all its files and state will be deleted permanently. These are Windows 10 virtual machines, the advantage of them is that they are built into Windows 10, so they use the existing OS, which provides faster startup, better performance and ease of use without losing security. The Windows Sandbox experience can also be customized using configuration files. This way you can add additional software and tools to your Windows Sandbox.

Windows Defender Application Guard

This may not be directly developmental. However, I think this has happened to everyone. We see a link and we are not sure whether it is a trusted site or a malicious site. With Windows Defender Application Guard we get a sandboxed browser that protects us from malicious websites and software. If a user navigates to an untrusted site through Microsoft Edge or Internet Explorer, Microsoft Edge opens the site in an isolated Hyper-V-enabled container that is separate from the host operating system.

Hyper-V Battery Pass-through

This feature is more about convenience. If you work and develop inside a virtual machine and use the virtual machine console in full screen mode, you may not notice when your laptop's battery is low. With Hyper-V Battery Pass-through, the guest operating system inside the virtual machine knows about the battery status. The Hyper-V Virtual Battery feature is enabled by default and works with Windows and Linux virtual machines.

Nested virtualization

Nested virtualization allows you to run virtualization on a virtual machine, basically like the initial stage for virtual machines.
With Hyper-V, you can run Hyper-V in a Hyper-V virtual machine. This is interesting for a couple of different scenarios. First, you can create a Hyper-V virtual host for testing and lab work, or more importantly, you can run Hyper-V containers or Windows Sandbox in a virtual machine. And another great thing about Nested Virtualization is that it also works with virtual machines in Microsoft Azure. To enable nested virtualization inside Hyper-V, you can study this guide.

How to set up Hyper-V on Windows 10

Now, as you can see, Hyper-V is a great tool for developers and is used for many different functions. To install Hyper-V, you must check the following requirements on your computer:

  • Windows 10 Enterprise, Pro, or Education.
  • 64-bit processor with Second Level Address Translation (SLAT).
  • CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs).
  • At least 4 GB of memory.

For more information and troubleshooting, see Windows 10: Hyper-V system requirements. For more information on how to install Hyper-V on Windows 10, see Microsoft documentation.

Starting the virtual machine

It is easy to launch the newly created VM by simply clicking on it 2 times or clicking “ Enable ”. When creating, you must indicate that the download will come from an ISO image or disk in order to immediately install the OS. If the image was not specified, then this is done in the “ Media ” line of the connection to the VM.

As a rule, after installation the VM boots from the virtual HDD, as this happens automatically. You can also configure the download if it does not work as expected from the HDD. To do this, you need to hover the mouse cursor over the name of the VM in the Hyper manager, right-click, then select the “ Parameters… ” line, then the “ BIOS ” line.

In the settings you can also change the size of the allocated RAM, the number of virtual processors, add additional HDDs and change other VM settings.

It is clear that this algorithm is brief and cannot fully accommodate all aspects and features of the process of creating and installing virtual machines V in Windows 10. Close attention should be paid to the following points: creating recovery points, connecting physical disks to the OS installed in the VM, etc. Further.

Rating
( 1 rating, average 4 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]