Migrating existing workloads to incus hosts can be a very easy and mostly automated process - if you are aware of the preconditions and necessary host preparation steps.
Planning the migration
The source machine you want to migrate to an incus instance must be a bootable installation, meaning either a real virtual or physical machine running a complete operating system.
You cannot migrate incus system container or OCI containers to incus following this guide in any way, but you can convert incus virtual machines into incus system containers using it (even on the same host).
All types of disk encryption are lost when migrating to an incus system container, as incus-migrate operates on the readable post-boot filesystem, which does not include the encrypted disk state (virtual machines will preserve LUKS disk encryption).
Finally, workloads depending on specific kernel modules can only be migrated to incus virtual machines (if at all), as system containers cannot load kernel modules.
Preparing the source machine
Start by stopping/disabling all workloads that may write to disk, including background workers and databases. Make a backup of all application data to be safe.
If converting to a virtual machine, you will need to know the boot type (UEFI/legacy) and secure boot settings. Run these commands to confirm and note their output:
sudo mokutil --sb-state
test -d /sys/firmware/efi && echo "UEFI boot" || echo "Legacy boot"If you want to migrate to an incus virtual machine, you will have to find out which disk (not volume group or partition) the root filesystem / exists on. Run:
lsblk -o NAME,TYPE,MOUNTPOINTSand find the mountpoint for /, then check what disk device it falls under. It will almost always be one of /dev/sda, /dev/vda or /dev/nvme0n1.
The primary disk will be migrated automatically, all other disks have to be copied into qcow2 images and transferred manually:
sudo qemu-img convert -p -f raw -O qcow2 /dev/sdc /path/to/sdc.qcow2The example mirrors /dev/sdc into /path/to/sdc.qcow2. Transfer this file to the incus host and repeat the process for all disks except the one containing the root filesystem.
Finally, install the package containing the incus-migrate command.
Debian-like distributions:
sudo apt install incus-extraRHEL-like distributions:
sudo dnf install incus-toolsNote that installing the package for incus-migrate does not install the entire incus runtime, only the utilities necessary for migration.
If you are migrating to an incus virtual machine instance instead of a system container, you will need to install the incus-agent service to be able to interact with it using standard incus commands afterwards.
Debian-like:
sudo apt install incus-agent
sudo systemctl enable incus-agent --nowRHEL-like:
sudo dnf install incus-agent
sudo systemctl enable incus-agent --nowThe agent could also be installed manually afterwards, but doing it before the migration streamlines instance access after migration.
Preparing the incus host
The target host you want to migrate the source machine to will need some setup as well.
First expose the incus HTTPS API so the source machine can reach it during migration.
For the special case where you want to migrate an incus vm to an incus system container on the same host, you can make it listen locally and proxy the host port into the vm instance:
incus config set core.https_address=127.0.0.1:8443
incus config device add my-incus-vm incusapi proxy \
listen=tcp:127.0.0.1:8443 \
connect=tcp:127.0.0.1:8443 \
bind=instanceUse https://127.0.0.1:8443 during migration.
For all other scenarios, instead make the incus host listen on all network interfaces:
incus config set core.https_address=:8443You can then reach the incus API by its public IP address on port 8443.
Finally, you will need a temporary trust token so incus-migrate can authenticate with the incus API:
incus config trust add migration-tokenNote the output token, you will need it in the next step. There is no need to remove it later, as it will be deleted automatically after first use.
Migrating to an incus daemon
Now is the time to finally run migration. Simply running the incus-migratecommand on the source machine will start the process:
incus-migrateAlternatively, you can supply most flags from incus launch to customize the newly created instance (notably excluding --vm):
incus-migrate -c limits.cpu=2 limits.memory=4GiB -d root,size=50GiBThe process will prompt for several pieces of information, all of which you should have gathered in the previous steps. If everything was done correctly, migration should be fully automatic after the prompts and produce a new instance on the incus host
You can also migrate a vm disk image using incus-migrate, but that is beyond scope for now.
Post-migration remediation
After migration has finished, verify that the new instance booted correctly. We assume you named your new instance new_instance, replace it with the real name you chose.
incus console new_instanceIf you have mirrored any additional disks into qcow2 files previously, you can now attach them to the instance:
incus config device add new_instance sampledisk disk \
source=/path/to/disk.qcow2 \
path=/path/inside/new_instanceOr alternatively first import them into a storage pool (default in this case) and attach them as volumes for easier access:
incus storage volume import default /path/to/disk.qcow2 my_secondary_disk
incus config device add new_instance my_disk disk \
pool=default \
source=my_secondary_disk \
path=/path/inside/new_instanceIf the instance booted successfully and you have added all desired disks, start a shell session inside the instance, all following commands will be run in there:
incus exec new_instance -- bashInside the new instance, verify that mount points and services are all functional now:
sudo findmnt --verify
sudo systemctl --failedAlso check /etc/fstab for possible issues or missing disks and correct them manually before proceeding.
Networking device configuration is likely also wrong, check current status:
nmcli connection show
nmcli device statusIf necessary, delete old connections and configure the new one, for example replacing my-old-eth0 with a new eth0 device using DHCP:
nmcli connection delete "my-old-eth0"
nmcli connection add type ethernet \
ifname eth0 \
con-name eth0 \
ipv4.method auto \
ipv6.method autoVerify that the network connection works as expected:
ip addr show eth0
ip route
resolvectl statusOnce everything looks good, try restarting workloads and dependency services, and verify they operate as expected.