Setting Up an Ubuntu Server on Hyper-V: A Step-by-Step Guide

Cyber Grover 🐱‍💻
6 min readMay 23, 2023

--

Hyper-V is a powerful virtualization platform offered by Microsoft, enabling users to create and manage virtual machines (VMs) on Windows servers. If you’re looking to set up an Ubuntu Server on Hyper-V, this article will guide you through the process, ensuring a successful installation.

I’ve successfully installed Ubuntu Server on Hyper-V on Windows Pro. The steps remain the same for Windows Server as well. Virtualizing Ubuntu with Hyper-V opens up a world of possibilities and flexibility for your server infrastructure.

Click on New to set up a new Virtual Machine
Specify a name for your Server
Specify a Generation for your Virtual Machine

Key differences between Generation 1 and Generation 2 VM setups:

Generation 1 VMs:

  1. BIOS-based: Generation 1 VMs use BIOS (Basic Input/Output System) firmware, similar to traditional physical computers.
  2. Limited virtual hardware: Generation 1 VMs provide a basic set of virtual hardware components, including IDE-based virtual hard disks, legacy network adapters, and standard input/output devices.
  3. Boot from legacy devices: Generation 1 VMs support booting from IDE-based virtual hard disks, DVD drives, and legacy network adapters.
  4. No Secure Boot: Secure Boot, a security feature that ensures only trusted operating systems are loaded during startup, is not available in Generation 1 VMs.
  5. Integration Services: Integration Services are available for Generation 1 VMs, providing enhanced performance and functionality through optimized drivers and services.

Generation 2 VMs:

  1. UEFI-based: Generation 2 VMs use UEFI (Unified Extensible Firmware Interface) firmware, which offers improved boot and initialization capabilities.
  2. Enhanced virtual hardware: Generation 2 VMs provide a more advanced set of virtual hardware components, including SCSI-based virtual hard disks, synthetic network adapters, and other modern input/output devices.
  3. Secure Boot support: Generation 2 VMs can enable Secure Boot, providing an additional layer of security during the boot process.
  4. Boot from UEFI devices: Generation 2 VMs support booting from UEFI-compatible virtual hard disks, DVD drives, and network adapters.
  5. Faster boot times: Generation 2 VMs typically boot faster compared to Generation 1 VMs due to the use of UEFI firmware.
  6. No legacy device support: Generation 2 VMs do not support legacy devices like IDE-based virtual hard disks or legacy network adapters.
  7. Integration Services: Generation 2 VMs have updated Integration Services specifically designed for UEFI-based systems, delivering improved performance and functionality.

When choosing between Generation 1 and Generation 2 VMs, consider the specific requirements of your environment. Generation 1 VMs are suitable for legacy operating systems or scenarios where advanced features like UEFI and Secure Boot are not necessary.

Generation 2 VMs are recommended for modern operating systems and provide better performance, security, and flexibility with their enhanced virtual hardware and UEFI capabilities.

Assign Memory. Do check Dynamic Memory option (See below)

When assigning memory to virtual machines (VMs) in Hyper-V, it is important to consider several factors to optimize performance and resource allocation. Several factors include

  1. Guest Operating System Requirements
  2. Workload and Application Requirements
  3. Host Server Resources
  4. Memory Ballooning
  5. Future Scalability
Configure Networking

The Default Switch is configured to use NAT by default. NAT allows the VMs connected to the Default Switch to share the host machine’s IP address for outbound network connections. The Default Switch automatically assigns IP addresses to the VMs using a built-in DHCP server.

Configure the Virtual Hard Disk

Hyper-V supports various file formats for virtual hard disks, including VHD and VHDX. VHD is the older format, while VHDX is the newer and more advanced format. VHDX offers improved performance, reliability, and larger capacity support compared to VHD. It serves as the storage medium for the VM, holding the operating system, applications, and data.

Select the Installation Media

To use the ISO option, you first need to download the Ubuntu ISO image file from the official Ubuntu website or a trusted source. The ISO file corresponds to a specific version and edition of Ubuntu (e.g., Ubuntu 20.04 LTS or Ubuntu Server).

Verify the options
The Virtual machine has been created
Right Click and select “connect”
ERROR

If the VM does not load and shows the above screen, follow the steps below.

Power Off the VM and select “Settings”
Disable Secure Boot Option

Secure Boot is a feature implemented in modern computer systems, including those running Hyper-V, to ensure that only trusted software is allowed to run during the boot process. However, when it comes to running Linux on Hyper-V, Secure Boot needs to be disabled due to several reasons:

  1. Unsigned Linux Bootloaders
  2. Limited Linux Bootloader Support
  3. Driver Compatibility

It’s important to note that disabling Secure Boot does not compromise the security of the system, as other security mechanisms such as secure connections, file permissions, and firewalls can still be implemented within the Linux environment.

Select the first option to Install Ubuntu Server
Installation Process…. Amazing View
Select your language
Select Ubuntu Server for installation. The minimized version usually runs in a Data-center
Automatic allotment of IP Address from DHCP Server
Hit Enter

LVM (Logical Volume Manager) is a disk management and partitioning system commonly used in Linux environments.

Deselect LVM

The details of LVM are beyond the scope of this tutorial. I urge you to read more about it on detail.

Setting up the filesystem
Press continue to setup Virtual Disk
Setup the Hostname and User Account
Skip for now
Install SSH server for SSH access later
We will skip these services for now as we will install them later as per use
Wait Patiently for installation
Congratulations!! Reboot Now
Login with Username and Password

Congratulations on setting up your Ubuntu Server on Hyper-V! You now have a powerful platform to host and manage various services and applications. By combining the stability and security of Ubuntu Server with the virtualization capabilities of Hyper-V, you can create a robust and flexible environment for your server needs.

Key points to keep in mind as you continue your journey:

  1. Configuration and Customization: Take some time to configure your Ubuntu Server according to your specific requirements.
  2. Updates and Maintenance: Regularly apply updates and security patches to keep your Ubuntu Server up to date and protected against vulnerabilities.
  3. Services and Applications: Identify the services and applications you want to run on your Ubuntu Server.
  4. Backup and Disaster Recovery: Implement a backup strategy to safeguard your server and data. Regularly backup important files, databases, and configurations to an offsite location or another storage medium.
  5. Monitoring and Performance Optimization: Monitor your server’s performance and resource utilization to identify any bottlenecks or issues.

--

--

Cyber Grover 🐱‍💻
Cyber Grover 🐱‍💻

Written by Cyber Grover 🐱‍💻

Cybersecurity Professional, Developer. Adept at system and network analysis, cyber threat intellignece and security frameworks.

Responses (1)