VMmanager 6: Administrator guide

How to move an OVZ container to LXD cluster?

ISPSystem

You can move a virtual machine (VM) created with OVZ virtualization to an LXD cluster. To move the VM:

  1. Save the information about permissions to VM files.
  2. Create an LXD container for the VM and clear it.
  3. Move the directory of the source VM to the created LXD container.
  4. Restore the permissions to VM files.

Note

You can apply this method only for moving VM to an LXD cluster with the "Switching" network configuration type.

  1. Update software packages to the latest version:

    yum update
  2. Install the acl package on the running VM:

    yum install acl
  3. Install the cloud-init package:

    yum install cloud-init
  4.  Save the information about permissions to VM files and directories:

    cd / && getfacl -R / > acl.save
  5. Stop the VM:

    Note

    If you use VMmanager 5 OVZ, stop the VM in the control panel: ManagementVirtual machines → select the VM → Stop button.

    vzctl stop 109

    109 — id of the OVZ container with the VM

  6. Save the VM directory to the archive:

    If you use simfs
    cd /vz/private/109/;tar -czf /109.tgz .
    If you use ploop
    mount -t ploop /vz/private/109/root.hdd/DiskDescriptor.xml /media/;cd /media;tar -czf /109.tgz .
  7. Copy the created archive to LXD cluster node.
  8. In the VMmanager interface, create a VM in the LXD cluster and stop it.

    Note

    Create a VM with the same OS and the same parameters as the original VM.

  9. Determine where the VM container is located:

    zfs list
  10. Mount the container with the created VM:

    zfs mount tank/containers/vm-624

    tank — ZFS pool name

    vm-624 — VM name

  11. Clear the container:

    rm -rf /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/*
  12. Unzip the archive from the original VM:

    tar -xf 109.tgz -C /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs
  13. Change the owner of the file system to the root user of LXD container:

    chown 1000000:1000000 /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/ -R
  14. Remove old network configuration files:

    rm /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/etc/sysconfig/network-scripts/ifcfg-venet*
  15. Edit /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/etc/sysconfig/network file:

    Example of file
    NETWORKING="yes"
    GATEWAYDEV="venet0"
    NETWORKING_IPV6="yes"
    IPV6_DEFAULTDEV="venet0"
    HOSTNAME="example.com"
  16. Create a new configuration file for the network interface:

    touch /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/etc/sysconfig/network-scripts/ifcfg-ens1
    File contents
    # Created by cloud-init on instance boot automatically, do not edit.
    #
    BOOTPROTO=none
    DEFROUTE=yes
    DEVICE=ens1
    DNS1=8.8.8.8
    DNS2=1.1.1.1
    DNS3=77.88.8.8
    GATEWAY=10.13.0.1
    IPADDR=10.13.0.156
    IPADDR1=10.13.0.157
    NETMASK=255.255.255.0
    NETMASK1=255.255.255.255
    ONBOOT=yes
    STARTMODE=auto
    TYPE=Ethernet
    USERCTL=no
  17. Unmount the container:

    zfs umount tank/containers/vm-624
  18. Delete the content of the directory /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/.

  19. Start the VM in VMmanager interface.

  20. Restore the permissions to VM files:

    lxc exec vm-624 bash
    cd / && setfacl --restore=acl.save
  21. Reboot the VM to apply the settings:

    reboot
  1. Update software packages to the latest version:

    apt update && apt upgrade
  2. Install the acl package on the running VM:

    apt install acl
  3. Download the cloud-init packages:

    curl -O https://download.ispsystem.com/external/cloud-init/stretch/cloud-guest-util_0.29-1_all.deb -O https://download.ispsystem.com/external/cloud-init/stretch/cloud-image-utils_0.29-1_all.deb -O https://download.ispsystem.com/external/cloud-init/stretch/cloud-init_20.2-2~deb10u1_all.deb -O https://download.ispsystem.com/external/cloud-init/stretch/cloud-utils-euca_0.29-1_all.deb -O https://download.ispsystem.com/external/cloud-init/stretch/cloud-utils_0.29-1_all.deb 
  4. Install the cloud-init package:

    dpkg -i cloud-*
    
    apt --fix-broken install -y
    dpkg -i cloud-*
  5.  Save the information about permissions to VM files and directories:

    cd / && getfacl -R / > acl.save
  6. Stop the VM:

    Note

    If you use VMmanager 5 OVZ, stop the VM in the control panel: ManagementVirtual machines → select the VM → Stop button.

    vzctl stop 109

    109 — id of the OVZ container with the VM

  7. Save the VM directory to the archive:

    If you use simfs
    cd /vz/private/109/;tar -czf /109.tgz .
    If you use ploop
    mount -t ploop /vz/private/109/root.hdd/DiskDescriptor.xml /media/;cd /media;tar -czf /109.tgz .
  8. Copy the created archive to LXD cluster node.
  9. In the VMmanager interface, create a VM in the LXD cluster and stop it.

    Note

    Create a VM with the same OS and the same parameters as the original VM.

  10. Determine where the VM container is located:

    zfs list
  11. Mount the container with the created VM:

    zfs mount tank/containers/vm-624

    tank — ZFS pool name

    vm-624 — VM name

  12. Clear the container:

    rm -rf /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/*
  13. Unzip the archive from the original VM:

    tar -xf 109.tgz -C /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs
  14. Change the owner of the file system to the root user of LXD container:

    chown 1000000:1000000 /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/ -R
  15. Edit the network interface configuration file:

    vi /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/rootfs/etc/network/interfaces
    File contents
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    source /etc/network/interfaces.d/*
  16. Edit the Cloud-init configuration file for network settings:

    vi /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-882-deb9v1/rootfs/etc/network/interfaces.d/50-cloud-init
    File contents
    # This file is generated from information provided by the datasource.  Changes
    # to it will not persist across an instance reboot.  To disable cloud-init's
    # network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    auto lo
    iface lo inet loopback
    
    auto ens1
    iface ens1 inet static
        address 10.13.0.162/24
        dns-nameservers 77.88.8.8 8.8.8.8 1.1.1.1
        gateway 10.13.0.1
  17. Unmount the container:

    zfs umount tank/containers/vm-624
  18. Delete the content of the directory /var/snap/lxd/common/lxd/storage-pools/zfs_pool/containers/vm-624/.

  19. Start the VM in VMmanager interface.

  20. Restore the permissions to VM files:

    lxc exec vm-624 bash
    cd / && setfacl --restore=acl.save
  21. Reboot the VM to apply the settings:

    reboot
Thank you for your feedback!
Was the article useful?
Tell us why not:

it does not match the title

it was hard to understand

I didn't find the answer

recommendations from the article did not help

other

Tell us what you didn't like in the article: