不少发行版会给一些 qcow2, vhd 之类的格式,专为虚拟机环境优化。在 PVE 上有 cloud-init 进行配置,而 HyperV 下却没得,本文以 Rocky-10-Azure-Base.latest.x86_64.vhdfixed.xz 为例记录一下怎么配密码。

Step.1

启动一个 wsl,装以下包

sudo apt install libguestfs-tools linux-image-generic

Step.2

Rename vhdfixed to vhd, and open a wsl shell doing:

sudo virt-customize -a Rocky-10-Azure-Base.latest.x86_64.vhd --root-password password:root

然后正常启动系统,用 root 就能登陆啦

Utils

# rocky mirror
sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.sustech.edu.cn/rocky-linux|g' -i.bak /etc/yum.repos.d/[Rr]ocky*.repo

dnf config-manager --enable crb

# epel mirror
sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!https\?://download\.fedoraproject\.org/pub/epel!https://mirror.sjtu.edu.cn/fedora/epel!g' \
    -e 's!https\?://download\.example/pub/epel!https://mirror.sjtu.edu.cn/fedora/epel!g' \
    -i /etc/yum.repos.d/epel{,-testing}.repo
Last modification:September 15, 2025
如果觉得我的文章对你有用,请随意赞赏