从lxd迁移到incus
Let’s talk about migration from lxd to incus. As for the reason, well I guess we have seen too much of this kinda “show” in the past half decade (just like CentOS to Rocky) so here is what happened in case you’re interested.
Technically I won’t take this as a tutorial since with the well-prepared tool lxd-to-incus by Stéphane Graber (Author of both lxd and incus) there’s nothing to do but simply running it, then everything seems working well.
PS: Tested PASS on both Debian Bookworm AMD64 (on Linux KVM based vm) and Armbian Bookworm ARM64 (on RK3566 based SBC).
这些年,同类剧本真是没少看。一言不合就闭源,一言不合就拉分支,完全不新鲜,具体就不多说了,开工干活。其实吧,作者给了迁移工具 lxd-to-incus ,所以实话说没啥可干的,执行一下就可以验证迁移后的结果了。
先检查系统现状。Check the system status at first.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# root @ bookworm-vm-host in ~ [17:55:15] $ uname -a Linux bookworm-vm-host 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux # root @ bookworm-vm-host in ~ [17:55:20] $ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" # root @ bookworm-vm-host in ~ [17:55:28] $ lxc --version 5.0.2 # root @ bookworm-vm-host in ~ [17:55:35] $ lxc list -c nsum4N +-------------+---------+-----------+--------------+------------------------+-----------+ | NAME | STATE | CPU USAGE | MEMORY USAGE | IPV4 | PROCESSES | +-------------+---------+-----------+--------------+------------------------+-----------+ | d10-test | RUNNING | 5s | 94.54MiB | 192.168.143.138 (eth0) | 6 | +-------------+---------+-----------+--------------+------------------------+-----------+ | d12-ngx | RUNNING | 6s | 107.81MiB | 192.168.143.2 (eth0) | 19 | +-------------+---------+-----------+--------------+------------------------+-----------+ | r8-app1 | RUNNING | 8s | 213.93MiB | 192.168.143.129 (eth0) | 235 | +-------------+---------+-----------+--------------+------------------------+-----------+ | u18-redmine | RUNNING | 19s | 402.67MiB | 192.168.143.158 (eth0) | 16 | +-------------+---------+-----------+--------------+------------------------+-----------+ # root @ bookworm-vm-host in ~ [17:55:39] $ |
然后根据文档,安装incus。Now install the incus (by Zabbly) according to the documentation.
从安装过程看,至少创建了一个用户,两个组,以及不少于6个systemd服务。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# root @ bookworm-vm-lxd in ~ [22:06:20] $ mkdir -p /etc/apt/keyrings/ && curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc # root @ bookworm-vm-lxd in ~ [22:07:42] $ sh -c 'cat <<EOF > /etc/apt/sources.list.d/zabbly-incus-stable.sources Enabled: yes Types: deb URIs: https://pkgs.zabbly.com/incus/stable Suites: $(. /etc/os-release && echo ${VERSION_CODENAME}) Components: main Architectures: $(dpkg --print-architecture) Signed-By: /etc/apt/keyrings/zabbly.asc EOF' # root @ bookworm-vm-lxd in ~ [22:08:02] $ which lxd-to-incus lxd-to-incus not found # root @ bookworm-vm-lxd in ~ [22:08:11] $ apt update && apt install incus Get:1 file:/etc/apt/mirrors/debian.list Mirrorlist [44 B] ....... Hit:7 https://pkgs.zabbly.com/incus/stable bookworm InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: alsa-topology-conf ........ xdelta3 Suggested packages: gvfs ........ xdelta3 0 upgraded, 226 newly installed, 0 to remove and 0 not upgraded. Need to get 259 MB of archives. After this operation, 924 MB of additional disk space will be used. Do you want to continue? [Y/n] y ........ ........ Setting up libgl1-mesa-dri:amd64 (22.3.6-1+deb12u1) ... Setting up incus-base (0.6-202402242339-debian12) ... Creating group 'incus' with GID 994. Creating group 'incus-admin' with GID 993. Creating user 'incus' (Incus user) with UID 994 and GID 994. Created symlink /etc/systemd/system/incus-lxcfs.service → /opt/incus/lib/systemd/system/incus-lxcfs.service. Created symlink /etc/systemd/system/multi-user.target.wants/incus-lxcfs.service → /opt/incus/lib/systemd/system/incus-lxcfs.service. Created symlink /etc/systemd/system/incus.socket → /opt/incus/lib/systemd/system/incus.socket. Created symlink /etc/systemd/system/sockets.target.wants/incus.socket → /opt/incus/lib/systemd/system/incus.socket. Created symlink /etc/systemd/system/incus-user.socket → /opt/incus/lib/systemd/system/incus-user.socket. Created symlink /etc/systemd/system/sockets.target.wants/incus-user.socket → /opt/incus/lib/systemd/system/incus-user.socket. Created symlink /etc/systemd/system/incus-startup.service → /opt/incus/lib/systemd/system/incus-startup.service. Created symlink /etc/systemd/system/multi-user.target.wants/incus-startup.service → /opt/incus/lib/systemd/system/incus-startup.service. Setting up libavutil57:amd64 (7:5.1.4-0+deb12u1) ... ....... Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.10+dfsg-1+b1) ... # root @ bookworm-vm-lxd in ~ [22:12:56] $ systemctl list-unit-files | grep incus incus-lxcfs.service enabled enabled incus-startup.service enabled enabled incus-user.service indirect enabled incus.service indirect enabled incus-user.socket enabled enabled incus.socket enabled enabled # root @ bookworm-vm-lxd in ~ [22:14:04] $ cat /etc/passwd | grep incus incus:x:994:994:Incus user:/var/lib/incus:/usr/bin/nologin # root @ bookworm-vm-lxd in ~ [22:14:32] $ cat /etc/group | grep incus incus:x:994:incus incus-admin:x:993: # root @ bookworm-vm-lxd in ~ [22:15:45] $ which lxd-to-incus /usr/bin/lxd-to-incus |
接下来就比较容易了,直接运行迁移工具即可。Now the only thing necessary is to run lxd-to-incus and it’s done.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# root @ bookworm-vm-lxd in ~ [22:15:59] $ lxd-to-incus => Looking for source server ==> Detected: .deb package => Looking for target server ==> Detected: systemd => Connecting to source server => Connecting to the target server => Checking server versions ==> Source version: 5.0.2 ==> Target version: 0.6 => Validating version compatibility => Checking that the source server isn't empty => Checking that the target server is empty => Validating source server configuration The migration is now ready to proceed. At this point, the source server and all its instances will be stopped. Instances will come back online once the migration is complete. Proceed with the migration? [default=no]: yes # 提示迁移过程中所有lxc会停止服务,迁移完成后则会自动恢复,回答yes则开始执行迁移 => Stopping the source server => Stopping the target server => Wiping the target server => Migrating the data => Migrating database => Writing database patch => Cleaning up target paths => Starting the target server => Checking the target server Uninstall the LXD package? [default=no]: yes # 询问是否卸载原本的lxd包,默认不卸载;我选择yes卸载,毕竟已经习惯了lxd相关命令,不卸载有可能误操作都不会意识到 => Uninstalling the source server # root @ bookworm-vm-lxd in ~ [22:19:46] $ incus list -c nsum4N To start your first container, try: incus launch images:ubuntu/22.04 Or for a virtual machine: incus launch images:ubuntu/22.04 --vm +-------------+---------+-----------+--------------+------------------------+-----------+ | NAME | STATE | CPU USAGE | MEMORY USAGE | IPV4 | PROCESSES | +-------------+---------+-----------+--------------+------------------------+-----------+ | d10-test | RUNNING | 4s | 16.86MiB | 192.168.143.138 (eth0) | 6 | +-------------+---------+-----------+--------------+------------------------+-----------+ | d12-ngx | RUNNING | 4s | 42.70MiB | 192.168.143.2 (eth0) | 24 | +-------------+---------+-----------+--------------+------------------------+-----------+ | r8-app1 | RUNNING | 5s | 94.29MiB | 192.168.143.129 (eth0) | 235 | +-------------+---------+-----------+--------------+------------------------+-----------+ | u18-redmine | RUNNING | 4s | 44.98MiB | 192.168.143.158 (eth0) | 16 | +-------------+---------+-----------+--------------+------------------------+-----------+ # root @ bookworm-vm-lxd in ~ [22:20:04] $ |
在容器内执行点啥,测试一下。Feel free to test something within the container.
1 2 3 4 5 6 7 8 9 10 11 |
# root @ bookworm-vm-lxd in ~ [22:30:12] $ incus exec d10-test -- cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" |
大佬干活真是,除停服不到4分钟外,妥妥的无缝迁移,没毛病。有时间可以把profile、network、storage等配置都检查一遍,我看了确实暂时没发现啥问题,关键我单机使用,存储也是本地硬盘,这要是都能出问题,大佬的名声就毁了。
The tool lxd-to-incus reminds me about migrate2rocky , which was also used on some of my cloud instances before another show started, kinda funny, right? The real world always could be far more absurd than fictions.
Anyway, still got some time? You’re encouraged to check the further configurations, such as profiles, network and backend storages – my test env is quite simple & straight forward, there should be no problem at all.
文章的脚注信息由WordPress的wp-posturl插件自动生成