Step 19 of 82
← Home
πŸ–₯️ Phase: Infrastructure

Step 19 Boot Linux ISO in Hyper-V

Why this step? Use virtualisation for safe testing environments before touching production.

Booting Linux ISO in Hyper-V

Complete guide for booting Linux distributions in Hyper-V virtual machines, including secure boot configuration and troubleshooting.

Overview

When installing Linux in Hyper-V Generation 2 VMs, you need specific security settings to allow the Linux ISO to boot properly.

Quick Fix

After creating your VM using the wizard:

  1. Right-click the VM β†’ Settings
  2. Go to Security section
  3. Under Secure Boot, select Microsoft UEFI Certificate Authority template
  4. Click OK

Step-by-Step Guide

Step 1: Create Virtual Machine

  1. Open Hyper-V Manager
  2. Right-click your host β†’ New β†’ Virtual Machine
  3. Click Next

Step 2: VM Configuration

Name:

Ubuntu-22.04-Desktop

Generation:

  • βœ… Choose Generation 2 (recommended for modern Linux)
  • ⚠️ Generation 1 works but is legacy

Memory:

  • Minimum: 2048 MB
  • Recommended: 4096 MB or more
  • βœ… Enable Dynamic Memory

Networking:

  • Select your virtual switch

Virtual Hard Disk:

  • Size: 20 GB minimum (50 GB+ recommended)
  • Location: Default or custom

Installation Options:

  • Select Install an operating system from a bootable image file
  • Browse to your Linux ISO

Step 3: Configure Secure Boot (Critical!)

Before starting the VM:

  1. Right-click VM β†’ Settings
  2. Navigate to Security
  3. Under Secure Boot, change template from:
    • ❌ Microsoft Windows (default)
    • βœ… Microsoft UEFI Certificate Authority
  4. Click OK

Step 4: Start VM and Install Linux

  1. Right-click VM β†’ Connect
  2. Click Start
  3. Boot from ISO
  4. Follow Linux distribution's installation wizard

Supported Linux Distributions

Confirmed Working

  • Ubuntu (18.04, 20.04, 22.04, 24.04)
  • Debian (10, 11, 12)
  • Fedora (all recent versions)
  • CentOS / Rocky Linux / AlmaLinux
  • openSUSE / SUSE Enterprise
  • Linux Mint
  • Pop!_OS
  • Manjaro
  • Arch Linux
  • Kali Linux

Common Boot Issues

Issue 1: Black Screen / Won't Boot

Cause: Using Windows secure boot template

Solution:

Settings β†’ Security β†’ Secure Boot Template β†’ Microsoft UEFI Certificate Authority

Issue 2: "Secure Boot Violation"

Solution 1: Change template (see above)

Solution 2: Disable Secure Boot entirely

Settings β†’ Security β†’ Uncheck "Enable Secure Boot"

Issue 3: ISO Not Detected

Check:

  1. Settings β†’ SCSI Controller β†’ DVD Drive
  2. Ensure ISO path is correct
  3. Try removing and re-adding the ISO

Issue 4: VM Starts in UEFI Shell

Solution:

  1. Power off VM
  2. Settings β†’ Firmware β†’ Boot Order
  3. Move DVD Drive to top
  4. Click OK and restart

Generation 1 vs Generation 2

Generation 2 (Recommended)

βœ… Advantages:

  • UEFI boot (modern)
  • Secure Boot support
  • Better performance
  • Faster boot times
  • Network boot (PXE)

❌ Disadvantages:

  • Requires 64-bit OS
  • Requires secure boot configuration

Generation 1 (Legacy)

βœ… Advantages:

  • No secure boot issues
  • Works with any Linux
  • Simpler setup

❌ Disadvantages:

  • BIOS boot (old)
  • Slower performance
  • Limited features

Post-Installation Configuration

Install Linux Integration Services

Most modern Linux distributions include Hyper-V drivers built-in. For older versions:

# Ubuntu/Debian
sudo apt install linux-tools-$(uname -r) linux-cloud-tools-$(uname -r)

# RHEL/CentOS
sudo yum install hyperv-daemons

# Arch Linux
sudo pacman -S hyperv

Enable Enhanced Session Mode

For better desktop experience:

# Ubuntu/Debian
sudo apt install xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp

Then in Hyper-V:

  1. Settings β†’ Enhanced Session Mode Policy
  2. βœ… Allow enhanced session mode
  3. Reconnect to VM

Configure Display Resolution

# Edit GRUB
sudo nano /etc/default/grub

# Add or modify this line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"

# Update GRUB
sudo update-grub

# Reboot
sudo reboot

Optimize Performance

# Disable IPv6 (if not needed)
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

# Apply changes
sudo sysctl -p

Networking Configuration

NAT Network

VM gets internet through host:

  1. Settings β†’ Network Adapter β†’ Virtual Switch
  2. Select Default Switch (NAT)

Bridged Network

VM gets IP from your router:

  1. Create External Virtual Switch in Virtual Switch Manager
  2. Settings β†’ Network Adapter β†’ Select your external switch

Storage Configuration

Add Additional Disk

  1. Settings β†’ SCSI Controller β†’ Add β†’ Hard Drive
  2. New β†’ Virtual Hard Disk
  3. Specify size and location
  4. In Linux:
# List disks
lsblk

# Partition new disk
sudo fdisk /dev/sdb

# Format partition
sudo mkfs.ext4 /dev/sdb1

# Mount
sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data

# Auto-mount on boot
echo '/dev/sdb1 /mnt/data ext4 defaults 0 0' | sudo tee -a /etc/fstab

Checkpoints (Snapshots)

Create VM snapshots for easy recovery:

# PowerShell on host
Checkpoint-VM -Name "Ubuntu-22.04" -SnapshotName "Fresh Install"

Or in Hyper-V Manager:

  • Right-click VM β†’ Checkpoint

Special Distributions

Arch Linux

Requires manual partitioning. During installation:

# Check if booted in UEFI mode
ls /sys/firmware/efi/efivars  # Should have files

# Partition disk
cfdisk /dev/sda

# Create:
# 1. 512MB EFI partition
# 2. Rest for root partition

Kali Linux

Enable Hyper-V graphics:

# After install
sudo apt update
sudo apt install xserver-xorg-video-fbdev

Troubleshooting Commands

Check Hyper-V Integration

# Check loaded modules
lsmod | grep hv_

# Should see:
# hv_vmbus
# hv_storvsc
# hv_netvsc

Check Network

# View interfaces
ip addr show

# Test connectivity
ping 8.8.8.8

Check Disk

# Disk usage
df -h

# Disk performance
sudo hdparm -Tt /dev/sda

Performance Tips

  1. Allocate enough RAM - 4GB minimum for desktop Linux
  2. Enable Dynamic Memory - Let Hyper-V manage RAM
  3. Use Generation 2 - Better performance than Gen 1
  4. Install Integration Services - For optimal drivers
  5. Use SSD host storage - Much faster than HDD

Security Considerations

Secure Boot Benefits

βœ… Prevents unauthorized bootloaders
βœ… Protects against rootkits
βœ… Validates kernel integrity

When to Disable Secure Boot

  • Custom compiled kernels
  • Third-party drivers
  • Some older distributions

Next Steps

After successful Linux installation:

  • See "XRDP met Cinnamon Desktop" for remote desktop setup
  • Check "Ubuntu 20.04 on Raspberry Pi" for ARM-based VMs
  • Review "Debian 10" manual for server configuration

Additional Resources