资讯详情

资讯详情

如何在 Lima 中启动 Windows 11 访客(QEMU 与 swtpm 环境准备)?

如何在 Lima 中启动 Windows 11 访客QEMU 与 swtpm 环境准备【免费下载链接】limaLinux virtual machines, with a focus on running containers项目地址: https://gitcode.com/GitHub_Trending/lim/lima在 Lima 中运行 Windows 11 访客是实验性功能自 Lima v2.2 起支持本文给出一条从环境准备到首次登录的完整路径宿主机装好 Lima、QEMU 和swtpm手动准备 Windows 11 安装 ISO然后执行limactl start template:windows启动实例。Windows 11 的硬件要求中包括 TPMLima 默认通过swtpm做 TPM 模拟来绕过这一检查所以宿主机上的swtpm是这条主路径的必备组件。文档中给出的要求一览见 Windows guest 文档⚡ RequirementLima 2.2, QEMU, swtpm准备条件安装 Lima 与 QEMU根据 安装文档Lima 支持的宿主机为macOS推荐最新版本、Linux、NetBSD未测试、DragonFlyBSD未测试、Windows未测试。若使用 QEMU driver宿主机需要安装 QEMU。以 Homebrew 为例安装 Limabrew install lima安装文档还列出了 MacPortssudo port install lima、Nixnix-env -i lima和二进制归档等安装方式任选其一即可。QEMU 的版本建议见 QEMU driver 文档macOSv8.2.1 或更高版本Linuxv6.2.0 或更高版本另外QEMU 是 Linux 宿主机上的默认 driver而 Windows 访客文档 明确说明 QEMU 是唯一支持 Windows 访客的 VM driver因此无论宿主平台如何本场景都必须准备 QEMU。安装 swtpm 并理解 TPM 开关Windows 11 访客默认启用 TPM 模拟Trusted Platform Module emulation因为 Windows 11 有相应的硬件要求。要使用 TPM 模拟必须在宿主机上安装swtpm。swtpm需要能在宿主机的 PATH 中找到。Lima 的 QEMU driver 在找不到该命令时会直接报错并给出提示错误信息形如摘自 qemu.go 中的定义swtpm not found in PATH: ... (hint: install swtpm)如果你不想安装swtpm可以关闭 TPM 模拟Lima 会随之绕过 Windows 11 的初始 TPM 检查。模板文件 中对应的字段是# Windows 11 guest uses TPM emulation by default. # You can turn off TPM (in that case, lima bypasses Windows 11s initial TPM check). tpm: true把它改为tpm: false即可在不安装swtpm的情况下启动代价是放弃 TPM 模拟。一个来自源码的边界限制swtpm在 Windows 宿主机上不受支持swtpm is not supported on Windows host见 qemu.go即 TPM 模拟依赖宿主机提供 Unix socket。手动下载 Windows 11 安装 ISO这是整条路径中唯一需要手动完成的下载。文档明确说明目前没有自动下载 Windows 11 ISO 的方式必须自行获取安装介质。下载地址文档指明的来源https://www.microsoft.com/en-us/software-download/windows11必须下载English (United States)版本否则虚拟机安装会在中途停止模板注释原文Otherwise VM installation is stopped in the middle。模板文件 中images.location的默认值为images: - location: ~/Downloads/Win11_25H2_English_x64_v2.iso arch: x86_64 - location: ~/Downloads/Win11_25H2_English_Arm64_v2.iso arch: aarch64也就是说x86_64 架构宿主机默认读取~/Downloads/Win11_25H2_English_x64_v2.isoaarch64 宿主机默认读取~/Downloads/Win11_25H2_English_Arm64_v2.iso。如果你下载的文件名或存放位置不同需要把模板中对应架构条目的location改为你自己的本地路径模板注释也明确要求set the local path here。virtio-win 驱动 ISO 不需要手动下载模板在osOpts.Windows.virtioWin中写好了下载地址与sha256:bbe6166ad86a490caefad438fef8aa494926cb0a1b37fa1212925cfd81656429校验值Lima 启动时会自动获取并校验。该驱动 ISO 是许多 QEMU virtio 选项qcow2 磁盘、virtio-net、virtio-serial、virtio-rng、virtio-keyboard、virtio-mouse所必需的。执行启动环境就绪后执行limactl start template:windows该命令基于内置的 windows-11 模板创建实例模板中的关键配置为os: Windows vmType: qemu plain: true模板头注释同时说明了约束Windows 访客目前是实验性功能只能在 QEMU 上运行且要求plain: true。可选的显示设置模板中video.display默认为default注释说明这是开发用途配置也可以设为none。验证与首次登录Windows 11 访客的用户密码是随机生成的并存储在虚拟机内的%USERPROFILE%\password.txt文件中。因此验证方式很直接完成 Windows 安装并首次登录桌面在用户目录下查看%USERPROFILE%\password.txt确认其中保存了本次使用的随机密码文档建议首次登录之后修改该密码。关于启动偶发失败的处置文档给出的方法是Booting Windows 11 may occasionally fail. If it fails, please delete the instance and try it again from scratch.即删除实例limactl delete 实例名实例名替换为limactl start输出中显示的实例名称删除后实例数据一并移除后重新执行limactl start template:windows从头再来。限制与已知问题以下限制均来自 Windows 访客文档 的 Caveats 部分规划使用方式前需要确认QEMU 是唯一支持 Windows 访客的 VM driver仅支持 plain 模式没有文件挂载file mount也没有动态端口转发dynamic port-forwardingprovision 功能仅有限支持没有boot、yq模式data和dependency模式存在限制Windows 11 安装 ISO 必须手动下载且必须为English (United States)版本。如果你要跑的不是 Windows 11 而是 Windows Server 2025对应命令是limactl start template:windows-2025且该模板默认关闭TPM 模拟与 Windows 11 模板的默认值相反启用 TPM 可例如用于安装 BitLocker 磁盘加密两者不要混用本文中的默认值假设。【免费下载链接】limaLinux virtual machines, with a focus on running containers项目地址: https://gitcode.com/GitHub_Trending/lim/lima创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
觉得有用,分享给同行:

为您的企业打造数字门面

稳重轻奢商务风格,端正雅致视觉,长效耐看不易过时。

立即咨询 →