关闭虚拟机后, 在宿主机中运行:
#! pwsh.exe
# 1. 设置 Hyper-V 允许的最大分辨率上限为 4K(这一步至关重要,决定了虚拟显存大小)
Set-VMVideo -VMName "Fedora-Silverblue" -ResolutionType Maximum -HorizontalResolution 3840 -VerticalResolution 2160
# 2. 设置单屏初始分辨率为 4K
Set-VMVideo -VMName "Fedora-Silverblue" -ResolutionType Single -HorizontalResolution 3840 -VerticalResolution 2160
开启虚拟机后, 在虚拟机中运行:
#! /bin/bash
# 下面 "3840x2160" 中的 "x" 是英文字母 "x", 不是数字乘号, 这里也不能用数字乘号.
sudo grubby --update-kernel=ALL --args="video=Virtual-1:3840x2160"
验证参数是否已经被添加:
sudo grubby --info=ALL
然后重启虚拟机, 进入显示设置选择对应的分辨率即可.
备用, 移除该参数:
sudo grubby --update-kernel=ALL --remove-args="video=Virtual-1:3840x2160"
如果是silverblue版本:
开启虚拟机后, 在虚拟机中运行:
#! /bin/bash
# 下面 "3840x2160" 中的 "x" 是英文字母 "x", 不是数字乘号, 这里也不能用数字乘号.
rpm-ostree kargs --append="video=Virtual-1:3840x2160"
然后重启虚拟机, 进入显示设置选择对应的分辨率即可.
如果想要删除虚拟机中附加的分辨率:
#! /bin/bash
rpm-ostree kargs --delete="video=hyperv_fb:3840x2160"