VM 类型
Lima 支持两种运行客户机的方式:
vmType 只能在创建实例时指定。 现有实例的 vmType 无法更改。
请参阅以下流程图来选择适合你的最佳 vmType:
flowchart host{"主机操作系统"} -- "Windows" --> wsl2["WSL2"] host -- "Linux" --> qemu["QEMU"] host -- "macOS" --> intel_on_arm{"需要在 ARM 上 <br> 运行 Intel 二进制文件?"} intel_on_arm -- "是" --> just_elf{"只需要运行 <br> Intel 用户空间(快速),<br> 还是整个 Intel VM(慢速)?"} just_elf -- "用户空间(快速)" --> vz just_elf -- "VM(慢速)" --> qemu intel_on_arm -- "否" --> vz["VZ"]
在 Lima v1.0 之前,默认 vmType 是 QEMU。 从 Lima v1.0 开始,Lima 将在 macOS(>= 13.5)上默认使用 VZ 来创建新实例, 除非配置与 VZ 不兼容。(例如,启用了 legacyBIOS 或 9p)
QEMU
“qemu” 选项使用 QEMU 来运行客户操作系统。
推荐的 QEMU 版本:
- v8.2.1 或更高版本(macOS)
- v6.2.0 或更高版本(Linux)
VZ
⚡ 要求 | Lima >= 0.14, macOS >= 13.0 |
---|
“vz” 选项使用 macOS Virtualization.Framework 提供的原生虚拟化支持。
配置示例:
limactl start --vm-type=vz --mount-type=virtiofs
# 使用 vmType: vz 而不是 qemu(默认)来运行 ubuntu 的示例
vmType: "vz"
images:
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
mountType: "virtiofs"
注意事项
- “vz” 选项仅在 macOS 13 或更高版本上受支持
- Virtualization.framework 不支持运行 “arm 上的 intel 客户机” 和反之亦然
已知问题
- “vz” 不支持
legacyBIOS: true
选项,因此像 centos-stream 和 oraclelinux 这样的客户机将无法工作 - 使用 “vz” 运行 lima 时,
${LIMA_HOME}/<INSTANCE>/serial.log
将不包含内核启动日志 - 在运行 macOS 13.5 之前版本的 Intel Mac 上,Linux kernel v6.2(由 Ubuntu 23.04、Fedora 38 等使用)已知在 vz 上无法启动。 kernel v6.3 及更高版本应该可以启动,只要通过 GRUB 启动。 https://github.com/lima-vm/lima/issues/1577#issuecomment-1565625668 这个问题在 macOS 13.5 中已修复。
WSL2
警告 “wsl2” 模式是实验性的
⚡ 要求 | Lima >= 0.18 + (Windows >= 10 Build 19041 或 Windows 11) |
---|
“wsl2” 选项使用 Windows 的 wsl.exe
提供的原生虚拟化支持(更多信息)。
配置示例:
limactl start --vm-type=wsl2 --mount-type=wsl2 --containerd=system
# 使用 vmType: wsl2 运行 Fedora 的示例
vmType: wsl2
images:
# 来源: https://github.com/runfinch/finch-core/blob/main/Dockerfile
- location: "https://deps.runfinch.com/common/x86-64/finch-rootfs-production-amd64-1690920103.tar.zst"
arch: "x86_64"
digest: "sha256:53f2e329b8da0f6a25e025d1f6cc262ae228402ba615ad095739b2f0ec6babc9"
mountType: wsl2
containerd:
system: true
user: false
注意事项
- “wsl2” 选项仅在较新版本的 Windows 上受支持(大致是 2019 年以来的任何版本)
已知问题
- “wsl2” 目前不支持 Lima 的许多选项。有关最新的受支持选项,请参阅此文件。
- 使用 “wsl2” 运行 lima 时,
${LIMA_HOME}/<INSTANCE>/serial.log
将不包含内核启动日志 - WSL2 需要
tar
格式的 rootfs 归档文件而不是 VM 镜像 - Windows 没有附带 ssh.exe、gzip.exe 等 Lima 在各个地方使用的工具。解决这个问题的最简单方法是运行
winget install -e --id Git.MinGit
(winget 现在也内置到 Windows 中),并将生成的C:\Program Files\Git\usr\bin\
目录添加到你的路径中。