将 LXC 容器移动到新 VM
在你当前的 VM 上创建快照
lxc_snapshot_publish_export.sh
lxc snapshot container_name snapshot_name通过检查显示的快照列表来验证创建的快照:
lxc_info_snapshot.sh
lxc info container_name如果你没有为快照命名,请查找最近的创建日期。它可能有类似 snap1 的默认名称。
从快照创建镜像
lxc_publish_image.sh
lxc publish container_name/snapshot_name --alias="image_alias" description="image_description"通过检查显示的镜像列表来验证创建的镜像:
lxc_image_info.sh
lxc image info image_alias将创建的镜像导出到当前路径中的归档
lxc_image_export.sh
lxc image export image_alias image_archive_name将文件发送到你的新 VM
确保你可以从旧 VM 建立到新 VM 的 SSH 连接,例如通过 VPN 或 Wireguard 连接。使用 scp 复制镜像,如下所示:
scp_image_to_new_vm.sh
scp ./image_archive_name.tar.gz usera@host:/home/user在新 VM 上导入镜像并启动新容器
确保你的新 VM 上安装了 lxc 和 lxd,然后按如下方式导入镜像:
lxc_image_import_launch.sh
lxc image import image_archive_name.tar.gz --alias image_alias_on_new_vm确保导入的镜像出现在你新 VM 的列表中。
lxc_image_list.sh
lxc image list然后使用以下命令从镜像启动新容器:
lxc_launch_container.sh
lxc launch image_alias_on_new_vm container_nameIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow