Home / Windows 10

Creating a Network Switch

By default, a new virtual machine is set up as a standalone computer with no network connection. It can't connect to the Internet or to other computers on your network. In this connected world, you'll probably want to give your virtual machines a network connection.

To do that, you must first have a bit of networking infrastructure in place-namely, a virtual switch. A virtual switch connects the virtual network adapter in your virtual machine to the physical network adapter in your physical computer, thereby allowing the virtual machine to connect to the outside world.

Note:
You can create and manage a virtual switch after you set up a virtual machine and then modify your virtual machine to use the virtual switch. Setting up the virtual switch before you set up your virtual machines simply saves a few steps.

To create a virtual switch or make changes to an existing one, in the Actions pane (or on the Action menu) click or tap Virtual Switch Manager. Then select the type of switch you want to create:

  • External:
    This is the most common type because it binds the virtual switch to your computer's physical network adapter so you can access your physical network. Assuming your physical network adapter is connected to the Internet, your virtual machines also have Internet access.
  • Internal:
    An internal virtual switch can be used only to make a connection among the virtual machines running on your physical computer, and between the virtual machines and your physical computer.
  • Private:
    Use a private virtual switch to set up a network that comprises only the virtual machines running on your physical computer. This network is isolated from all physical computers, including the one on which it's installed.

When you click or tap Create Virtual Switch, you're asked for more details. Click OK to complete the switch creation.

Creating a virtual machine

With your virtual network switch in place, you're ready to create a new virtual machine. To do that, in the Actions pane, click or tap New, Virtual Machine, which launches the New Virtual Machine Wizard. You navigate through the wizard, which leads you through the process of setting up a virtual machine, by using the Next and Previous buttons or the links along the left side. At any point in the wizard, you can click Finish to create a virtual machine that uses default values for any wizard pages you skip.

Specify name and location

After you step through the Before You Begin page, the wizard asks you to provide a name for your virtual machine. Enter a name or description that'll help you differentiate this virtual machine from others you might create. If you don't like the proposed storage location for the virtual machine files, select the check box and specify another.

The default location is %ProgramData%\Microsoft\Windows\Hyper-V\. (%ProgramData% is an environment variable that is set to C:\ProgramData on a standard Windows installation.) If your computer has a small system drive (common in systems that use a solid state drive for system files and a large hard disk for data files), you might want to store the files elsewhere. Keep in mind that a virtual machine can occupy 10-40 GB or more.

It is possible to move the virtual machine files after you create the machine, but it's not easy. Although some parts of a virtual machine (the virtual hard disk and the paging file, for example) can be moved by changing the settings of the virtual machine, this option isn't available for some of the core files. To completely move a machine at a later time, you can import a virtual machine, copy it, and store it in a different location. You're much better off choosing a suitable location before you create the virtual machine.

Specify generation

On the next wizard page, you select either Generation 1 or Generation 2 for the style of virtual machine you need.

This choice is new to Hyper-V in Windows 10 and offers some tradeoffs between compatibility and features.

Generation 1 supports a wide range of guest operating systems, including most versions of Windows (32-bit and 64-bit) and Linux. The virtual hardware in a generation 1 virtual machine is typical of that found in BIOS-based PCs for many years.

Generation 2 supports only a few guest operating systems: 64-bit versions of Windows 8, Windows 8.1, Windows 10, Windows Server 2012, and Windows Server 2012 R2. In addition, generation 2 removes support for attaching physical DVD drives and other older hardware to a virtual machine. But a generation 2 virtual machine has modern UEFI-based firmware, which enables Secure Boot and booting from a network adapter, SCSI hard drive, or DVD. In addition, generation 2 virtual machines enable new Hyper-V features, such as the ability to adjust memory or add a network adapter while the virtual machine is running.

If you're going to install one of the newer supported operating systems in your virtual machine, select Generation 2 to enable additional features. For an older operating system, you must stick with the default option, Generation 1.

Note:
If you select Generation 2, you must install the operating system from an ISO file; you can't use a DVD.

Assign memory

On the Assign Memory page, you specify the amount of RAM your virtual machine will have.

If you enable Dynamic Memory, Hyper-V uses memory as a shared resource that can be reallocated as needed among running virtual machines. This way, each machine gets as much memory as it needs, but it doesn't reserve a fixed amount of memory (which would preclude other machines from using it).

Therefore, if you plan to run more than one virtual machine at once, we recommend that you select Dynamic Memory to get the best performance. Then set Startup Memory to at least the minimum amount required for the operating system you plan to install in this virtual machine.

If you plan to run only one virtual machine, or if you know how much memory your virtual machine will need to perform its given tasks, you can turn off Dynamic Memory and specify a fixed amount of memory. This setup works more like a physical computer, in that whatever memory you specify is the total amount of installed RAM in the virtual machine.

Configure networking

On the next wizard page, you specify the virtual network switch where you want to connect your virtual machine's network adapter. The default option is Not Connected, which results in a virtual machine that's isolated from all other computers (physical and virtual) and from the Internet. Even to connect to the physical computer on which the virtual machine runs, you must create a virtual network switch and select it here.

Troubleshooting:
Before you can connect to a network, you must create a virtual network switch. Each virtual network switch you create appears in the Connection list.

To determine which type of network switch you're using (External, Internal, or Private), you need to return to the Virtual Switch Manager.

Connect virtual hard disk

On the Connect Virtual Hard Disk page, you set up the virtual machine's first virtual hard disk (VHD). (Just like a physical computer, a virtual machine can have multiple hard drives.) A virtual hard disk is actually a file in the VHD or VHDX format. By default, it's created in a subfolder of the virtual machine location you specified earlier. But you can override that default and store the virtual hard disk on any physical disk that's accessible to the host computer running Hyper-V.

In addition to specifying the name and location of your virtual hard disk file, you must specify the disk's capacity in gigabytes. Be sure you create a virtual hard disk that's big enough to store the operating system, programs, and data you plan to use on the virtual machine. Although you don't want to go overboard, don't worry too much about specifying a size that's too big. Because of the way data is stored in a virtual hard disk, the size of the VHDX file roughly corresponds with the amount of disk space in use rather than the size you specify, which is the maximum. However, its dynamically expanding nature also means that the VHDX file can grow to that maximum size; be sure that the physical hard drive where you store it has enough room to accommodate growth.

Note:
You can change the location later, but it's a multistep process. And it is possible to resize a virtual hard disk after it has been created, but doing so brings some risk of data loss. (For more information, select the virtual hard disk in the Settings window for the virtual machine, and then click Edit.) Therefore, it's best to get it right from the beginning.

If you have an existing virtual hard disk you want to use instead of creating a new one, select the second or third option on this wizard page.

Installation options

You use the wizard's next page, to specify how and when you want to install an operating system in your new virtual machine.

Like a physical computer, a virtual machine is nothing without an operating system, so installing one should be your first order of business. Select the appropriate option, specify the location of your operating system installation media, and click Next.

This brings you to a Summary page, where you can review your settings before clicking Finish to complete the wizard.

At this point, even though you've specified installation options, you still don't have a working virtual machine. Now back in Hyper-V Manager, double-click the new virtual machine to open it in a Virtual Machine Connection window. Then click or tap the Start button on the toolbar or choose Start on the Action menu. This "powers on" your virtual machine and launches operating system setup from the location you specified in the wizard.

More: Windows 10 Tutorials