Skip to content

Instantly share code, notes, and snippets.

@ramonsmits
Forked from PatrickLang/Fedora34-VM.ps1
Last active July 24, 2023 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramonsmits/9d5807a697dff2794264d6cde20ac5cc to your computer and use it in GitHub Desktop.
Save ramonsmits/9d5807a697dff2794264d6cde20ac5cc to your computer and use it in GitHub Desktop.
Hyper-V example setup for Fedora Workstation 38
# 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 38" -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-38-1.6.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment