multipass通过自定义镜像创建实例
本地qcow2创建实例
要指定本地 .qcow2 镜像文件,需要使用 file:// 前缀
# 绝对路径
multipass launch --name my-ubuntu --cloud-init user-data.yaml file:///path/to/your/aliyun_3_arm64_20G_nocloud_alibase_20250629.qcow2
# 相对路径
multipass launch --name my-ubuntu --cloud-init user-data.yaml file://$(pwd)/aliyun_3_arm64_20G_nocloud_alibase_20250629.qcow2
构建 multipass 命令
使用 multipass launch 命令,并按照以下格式组合参数:
--name my-ubuntu:为你的实例指定一个名字。
--cloud-init user-data.yaml:指定云初始化配置文件。
file:///path/to/your/aliyun_3_arm64_20G_nocloud_alibase_20250629.qcow2:指定本地镜像文件的完整路径。
注意事项
仅限 Linux 支持:根据 Multipass 官方文档,从本地文件或 URL 启动自定义镜像的功能目前仅支持 Linux 主机。在 macOS 和 Windows 上,你将收到错误提示,不支持 file:// 和 http:// 类型的镜像路径。
镜像兼容性:你使用的 .qcow2 镜像必须是 cloud-init 兼容的镜像,并且需要包含 cloud-init 和 SSH 服务,否则 Multipass 无法对其进行配置和访问。阿里云的 nocloud 镜像通常符合这些要求。
Hypervisor:在 macOS 上,Multipass 默认使用 qemu 作为驱动。在 Linux 上,它也使用 qemu。