How to Run Linux on Hyper-V?

Running Linux on Hyper-V allows you to combine the stability of Microsoft’s virtualization platform with the versatility of open-source operating systems. Whether you’re exploring Linux for education, testing or production environments, Hyper-V provides a reliable way to deploy and manage virtual machines efficiently.

Among the many supported distributions, Ubuntu Linux stands out for its simplicity and broad compatibility. With proper configuration, you can achieve excellent performance and integration between Linux and Windows. Read this blog post to learn how to install, configure and optimize Linux on Hyper-V step by step.

NAKIVO for Hyper-V Backup

NAKIVO for Hyper-V Backup

Agentless, application-aware backups for Hyper-V. Anti-ransomware protection, instant VM boot from backup, other virtual/physical platform support and more.

Reasons to Run Linux on Hyper-V

The popularity of Linux is growing and this operating system is time-tested. Let’s have a look at the most common reasons to install Linux on Hyper-V:

  • You need to test a particular Linux distribution in your Hyper-V virtual environment. For example, a new Linux version has recently been released and you want to test it before installing it on physical servers.
  • You want to run containers. Linux offers excellent container support, which may be a compelling reason to install Linux as a virtual machine on Hyper-V.
  • Testing multi-platform software or software that provides similar functionality. This is a great option when developers make their applications compatible with multiple operating systems, such as Windows, Linux and Solaris (for example, Oracle Database). You can install the appropriate software on Linux to test it. If the experiment is successful, you can install Linux and the supported software in your production environment.
  • Licensing. This point is related to the previous one. Contrary to Windows, Linux is free. You must pay for each Windows instance installed on a Hyper-V VM that exceeds the number of Windows licenses included in your edition. This does not apply to the Datacenter Edition license.
  • Linux requires fewer hardware resources than Windows. Windows is a resource-intensive operating system, whereas Linux is lightweight. 
  • Linux is secure. Windows systems are generally vulnerable to a variety of harmful viruses, whereas Linux is somewhat safer, especially if the system is configured correctly. Most viruses are developed for Windows. In most cases, you need to go to great lengths to execute a virus on Linux. Additionally, multiple Linux distributions are commonly used, making it more difficult for a virus to spread.
  • A Linux shell, such as bash, is essential for automating tasks. You can use regular expressions, scripts, and other tools to manage Linux effectively. Most vulnerabilities are quickly fixed.
  • You want to learn Linux to migrate from Windows to Linux

You can use converters to convert your physical servers to Hyper-V VMs in two steps. First, VMware vCenter Converter converts a physical machine into a VMware VM, and then Microsoft Virtual Machine Converter converts the VMware VM into a Hyper-V VM. 

Before You Begin

You can select any Linux distribution you like and install it by using the explained logic. One of the main differences between different Linux families is the different package managers you’re required to use. Package managers are intended to install, configure, upgrade and delete programs on Linux systems. 

Package managers help to resolve tasks such as:

  • Downloading packages. The packages are automatically downloaded from the most suitable software repository when you enter the command to install a particular package or application. They include metadata such as the software version, the architecture for which the package is built, checksums and other necessary packages to work properly.
  • Resolving dependencies. When you install software, it may require its own specific packages, including libraries. Finding, downloading and installing all this manually consumes a lot of time and effort. Package managers inform you about dependencies and suggest installing the necessary packages automatically.
  • Quality control. Software packages stored in authorized software repositories are tested to ensure high quality, stability and the absence of bugs.
  • The standard of file locations is respected. Linux contains a large number of files and directories. Sometimes, different Linux distributions use different paths for storing files, as well as using different configuration file names. Package managers allow you to follow the standards and store files in the required locations for each Linux distribution.

Before selecting a Linux distribution to install on Hyper-V, you can familiarize yourself with the Linux package managers. Some of the most popular Linux distributions and package managers are listed in the table below.

Linux distributions

Package managers used

Debian, Ubuntu, Kubuntu, Xubuntu, Lubuntu, Mint

APT (Advanced Packaging Tool), DPKG (Debian Package Management System)

OpenSUSE, SLES (SUSE Linux Enterprise Server)

Zypper, YaST

Red Hat, CentOS, Fedora

RPM (Red Hat Package Manager), YUM (Yellowdog Updater Modified)

Gentoo

Portage

As previously mentioned, the installation of Ubuntu Linux on Hyper-V will be demonstrated. If you don’t need the graphical user interface (GUI), you can install Ubuntu Server. Let’s download the ISO image of Ubuntu 24 LTS from the official website.

Creating a New Hyper-V VM

First, make sure that the Hyper-V role (feature) is enabled on your Windows machine (go to Control Panel > Programs and Features > Turn Windows features on or off and verify whether the check box near the Hyper-V string is ticked). Read how to install Hyper-V on Windows in detail.

To create a new virtual machine, open Hyper-V Manager and click Action > New > Virtual Machine. The New Virtual Machine Wizard should appear. 

ALT: Creating a new VM in Hyper-V Manager

  1. Before You Begin. There is nothing to configure at this step. Click Next.
  2. Specify Name and Location. Enter your VM name, for example, Ubuntu24 and select the folder where you will store the new VM. Try to use volumes that are different from your system volume C: . In this case, a directory on disk D: is used (D:VirtualHyper-V). You can enter the path manually or select the location by clicking Browse. Click Next when done.

    ALT: Choosing the name and location for the VM

  3. Specify Generation. Choose the generation of this virtual machine – Generation 1 or Generation 2. Generation 1 is selected in this example due to better compatibility. Generation 1 uses BIOS and Generation 2 uses UEFI for VM boot (you should disable Secure Boot in VM settings for Linux if you use Generation 2 and UEFI). Click Next to continue.

    ALT: Selecting the generation of the VM

  4. Assign Memory. Specify at least 1 GB of memory for your Ubuntu Linux machine with a GUI. You can edit memory settings after VM creation. Tick the Use Dynamic Memory for this virtual machine checkbox to use your hardware memory resources more efficiently. Click Next.

    ALT: Specifying the amount of memory

  5. Configure Networking. Select the virtual switch to which the virtual network adapter of your VM will be connected. The Default Switch is used in this case. Later, you can create and configure other virtual switches and connect your VM to the appropriate networks. Click Next.

    ALT: Selecting a virtual switch to connect

  6. Connect Virtual Hard Disk. Select the Create a virtual hard disk option. A dynamic VHDX virtual disk is created by default. Enter the virtual disk name (for example, Ubuntu24.vhdx), select the location and set the size of the virtual disk (at least 16 GB). Click Next.

    ALT: Connecting a new virtual disk the new VM

  7. Installation options. Select Install an operating system from a bootable CD/DVD-ROM. Select Image file (.iso) and browse the ISO installation image of Ubuntu 24 that you previously downloaded. Once done, click Next.

    ALT: Selecting installation options

  8. Summary. Check your settings in the installation summary and click Finish to create the new virtual machine.

    ALT: The new VM configuration summary

Set the Static MAC Address

Now that your new empty VM has been created, you can edit the different VM settings, such as the MAC address. It is better to use a static MAC address for Linux running on Hyper-V, especially if your Linux VM needs to be migrated between Hyper-V hosts. 

  1. Right-click your VM name and click Settings.
  2. In the Settings window, select your network adapter and expand the network adapter options by clicking the + icon.
  3. Click Advanced Features and select a static MAC address. 
  4. Click OK to save changes.

ALT: Defining a static MAC address for the virtual network adapter

Installing Ubuntu Linux on the VM

In Hyper-V Manager, select your Ubuntu virtual machine, right-click the VM name, and then select Connect from the context menu to open VMConnect. Alternatively, you can click Action > Connect in the menu bar of the Hyper-V Manager Window after selecting the VM. 

ALT: Connecting to a VM with VMConnect

In the VMConnect window, click the Start button to power on the VM. 

The virtual machine should be loaded from the ISO image. Then you can see the graphical user interface of the Ubuntu installer. The installer provides multiple configuration steps in the wizard mode.

  1. Welcome. On this screen, you can view the Ubuntu interface. Click Install Ubuntu.

    ALT: Starting to install Ubuntu on Hyper-V using the Ubuntu installer

  2. Choose your language. First, select the language of the user interface. Click Next to continue.

    ALT: Selecting a language

  3. Accessibility in Ubuntu. You can customize Ubuntu to meet your needs before setting it up. You can change them later in System Settings. Proceed to the next step.
  4. Keyboard layout. Select your keyboard layout (for example, English US) and click Next.
  5. Connect to the internet. Select Use wired connection and click Next.
  6. Installing updates. The installer recommends updating Ubuntu to the latest version for improved reliability and additional features. You can do this during installation by clicking Update now or skip this step and install updates later.
  7. What do you want to do with Ubuntu? Select Install Ubuntu.
  8. Type of installation. How would you like to install Ubuntu? Select the Interactive installation option and continue.
  9. Applications to install. What apps would you like to install first? Select Default selection (just the essentials, web browser and basic utilities) or Extended selection (an offline-friendly selection of office tools, utilities and web browser) depending on your needs.
  10. Optimise your computer. Optionally, you can install recommended proprietary software by selecting the appropriate checkboxes:
    • Install third-party software for graphics and Wi-Fi hardware (including, but not limited to, NVIDIA drivers and similar).
    • Download and install support for additional media formats (including, but not limited to, MP3, MP4, MOV and similar).
  11. Disk setup. Select how you want to install Ubuntu. You should prepare a disk, create a new partition scheme and format the partitions. There are two options:
    • Erase disk and install Ubuntu – the installer automatically creates the partition layout on the disk. This option can be used to automatically partition disks. If you are installing Ubuntu Linux for the first time, you can select this option.
    • Manual installation – you create the partition layout manually for a high level of customization. By selecting this option, you can manually create partitions of the necessary size and mount them to the appropriate directories. Skilled users widely utilize this option.

    ALT: Selecting the installation type for Ubuntu

    The advanced features include:

    • Encrypt the new Ubuntu installation for security. This option will not be enabled in the current example.
    • Use LVM with the new Ubuntu installation. LVM is the Logical Volume Manager that allows you to use an abstraction layer and create a volume group by using two logical or physical disks (or two virtual disks in the case of Linux on Hyper-V). Moreover, if you have no free space available on your volume, you can add another disk to the volume group and extend its size. This approach adds more flexibility, which can be useful for file servers, database servers and other similar applications. LVM allows you to resize volume groups and perform other operations on the fly without powering off your Linux machine.

    If you select manual installation, be aware of the Linux disk partitioning principles and standards.

    In Linux, disk partitions are not named using disk letters, such as C: or D:, as they are in Windows. In Linux, disks are named /dev/sda, /dev/sdb, /dev/sdc, etc. If the disk is named /dev/sda and has three partitions, the partition names should be /dev/sda1, /dev/sda2 and /dev/sda3. sda means SATA Disk.

    Disk partitions are mounted to directories that are called mount points. The main directory of the Linux file system is the root directory, which is denoted by the forward slash (/) symbol. The recommendations for creating the partitioning scheme manually for Linux are displayed in the table below. You can use a similar partition scheme when you install Linux on Hyper-V.

    Mount point

    Disk partition

    Recommended size

    Comment

    /boot

    /dev/sda1

    500 MB – 1 GB

    Contains the boot loader, such as GRUB

    /

    /dev/sda2

    at least 12-20 GB

    The most important partition that is required

    /home

    /dev/sda3

    Used to separate user files and system files

    swap

    /dev/sda4

    4-8 GB, depending on the amount of RAM

    The swap partition used for the same purpose as the Windows swap file

    /var/log/

    /dev/sdb1

    Creating a separate partition for storing logs is not necessary, but is recommended for servers. If you have applications that intensively write log files, your disk may become full. The operating system and applications can crash as a result.

    Note that you can create only 4 partitions if the Master Boot Record (MBR) partitioning scheme is used. GPT (GUID Partition Table) allows you to create more than 4 partitions. If you selected the Generation 2 VM in Hyper-V, the UEFI boot partition (mounted as /boot/efi) is required.

    Click Next to continue.

  12. Create your account. Enter your name, your computer’s name (a hostname for your VM in this case), pick a username and define the password. Confirm your password. You can select the appropriate option to log in automatically if needed. A password is required to log in by default. This is the most secure option and the one that is recommended. Click Next to continue.

    ALT: Configuring the computer’s name, username and password

  13. Select your time zone. Select your geographical location and time zone. Software repositories located in your region should be used for better availability and downloading speed. Click Continue.

    ALT: Selecting a location and a time zone for Ubuntu installation

  14. Ready to install. Review the summary of your chosen settings and click Install.

    Wait until the installation process is complete.

  15. Installation Complete. You need to restart the computer to use the new installation. Click Restart Now.

After restarting the Hyper-V Linux virtual machine, you can see the login screen. Select your username and enter your password to log in. Check the What’s New window that shows the new features of the new version of Ubuntu Linux that you have already installed on Hyper-V.

People also read