Skip to content

Instantly share code, notes, and snippets.

@PatrickLang
Last active September 27, 2023 10:31
Show Gist options
  • Save PatrickLang/03dcda94a93b8b2960aa41c29ded057f to your computer and use it in GitHub Desktop.
Save PatrickLang/03dcda94a93b8b2960aa41c29ded057f to your computer and use it in GitHub Desktop.
Hyper-V example setup for Fedora 34
# Echo the commands as they're run
Set-PSDebug -Trace 1
# Dump Windows version
Get-ComputerInfo | Format-Table WindowsVersion, OsVersion
# Create a UEFI VM, secure boot enabled, use the secure boot settings for the
$vm = New-VM -Generation 2 -Name "Fedora 34 beta" -Path .
$vm | Set-VMFirmware -EnableSecureBoot On -SecureBootTemplate "MicrosoftUEFICertificateAuthority"
# Disable the automatic checkpoints on each reboot. It's better to use snapper+btrfs :)
$vm | Set-VM -AutomaticCheckpointsEnabled $false
# Processor, memory settings
$vm | Set-VMProcessor -Count 2
$vm | Set-VMMemory -DynamicMemoryEnabled $false -StartupBytes 2Gb
# Add DVD drive, attach ISO, HDD, and set boot order
$dvd = $vm | Add-VMDvdDrive -Path ./Fedora-Workstation-Live-x86_64-34_Beta-1.3.iso -Passthru
$vhd = New-VHD -SizeBytes 20Gb -Dynamic boot.vhdx
$hdd = $vm | Add-VMHardDiskDrive -Path $vhd.Path -Passthru
$vm | Set-VMFirmware -BootOrder $dvd, $hdd
# Connect the network adapter - run Get-VMSwitch if you're not sure which name to use.
# There is a "Default switch" if you want a local NAT, but I prefer using a direct connection
$vm | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "External"

After installation - if you want to change the resolution, you need to change a boot setting. The hyperv_fb supports resolutions up to 1920x1080.

sudo grubby --update-kernel=ALL --args="video=hyperv_fb:1920x1080"
sudo reboot
@jiayaoO3O
Copy link

Will using Hyper-V directly conflict with WSL2 ?

@sha-w
Copy link

sha-w commented Oct 13, 2021

@jiayaoO3O No it will not. As a point of fact I believe the biggest trade off folks face if they wish to use WSL2 is they must enable hyper v. Which chains them to it.
Meaning they would be unable to use other virtualization technologies. Such as parallels, virtualbox, vmware and others. On the same windows install.
This is my understanding and it may be flawed, if it is, kindly correct the record!

@dtw
Copy link

dtw commented Jun 5, 2022

This worked great for me. Do I need to keep the ISO in-path permenantly, though?

@nowrozidavoud
Copy link

Hello Dears;
I have installed a fedora in windows 10 by hyper-v
after first boot ; install it on hard disk.
But when I start it ;boot in live mode(iso)
How can I set it to boot from installed version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment