Your web hosting partners since 2004.
Buy now »

How To Migrate OpenVZ 6 Containers to OpenVZ 7 Host

OpenVZ 6 reached End Of Life as of September 2019. If you're still hanging on, you'll want to migrate away.

It is advised to use OpenVZ 7 version instead. OpenVZ 7 has some major benefits, including:

  • Availability of the latest kernels
    • One of the major issues facing the OpenVZ 6 version was the kernel as it was running with 2.6.x kernels. The updated version will be coming with the 3.x kernel versions and possibly an upgrade is expected to the latest ones.
  • Security updates
    • The OS and software upgrades will always provide better security options, and it obviously increases the security of the VMs hosted in it.
  • Availability of New OS templates
    • The OpenVZ 7 is has the latest OS template support such as Centos 8, Ubuntu 18 and above, Debian 10 etc.

How to Upgrade

It's a common question, is it possible to upgrade the current OpenVZ6 to OpenVZ7 without reinstalling from scratch?

Unfortunately, But the answer is No.

You need a fresh server installed with OpenVZ 7 installed on it.

With this, it is possible to migrate the OpenVZ 6 containers to OpenVZ 7 from a control panel such as SolusVM, Virtualizor etc.

If you don't have a control panel, you'll want to do it manually.

Setup SSH

In order for vzmigrate to work without asking for a password, SSH public keys from the source host should be placed in the target /root/.ssh/authorized_keys file.

First, get a copy of your source root id_rsa.pub file:

# ssh root@source.example.com "cat /root/.ssh/id_rsa.pub">source_root_id_rsa.pub

Then we need to put that into the root authorized_keys file:

# cat source_root_id_rsa.pub | ssh root@target.example.com "cat >> /root/.ssh/authorized_keys"

To confirm, you should be able to run the following command:

# ssh root@source.example.com "ssh root@target.example.com 'echo worked!'"
  • Note: If you get the message Are you sure you want to continue connecting (yes/no)?, you can say yes.

Transfer

The first thing to note is that you can't use the vzmigrate as you may have done in the past, you have to use the ovztransfer.sh script.

  • Note: If you try and use the vzmigrate command, you'll get the error "OpenVZ is not running on the target machine".
wget https://src.openvz.org/projects/OVZL/repos/ovztransfer/raw/ovztransfer.sh

Usage looks like this:

# bash ovztransfer.sh
ovztransfer.sh version 1.2.0
Usage: ovztransfer.sh HOSTNAME SOURCE_VEID0:[TARGET_VEID0] ... [SOURCE_VEIDn:[TARGET_VEIDn]]

For example:

# bash ovztransfer.sh target.example.com 101:201
  • Replace target.example.com with your target server hostname.
  • Replace 101 with the source container ID (CT ID).
  • Replace 201 with the target container ID (CT ID).
# bash ovztransfer.sh target.example.com 101:201
Checking target host parameters...
Migration of Container 101 started
Container 101: Shutting down all possible services...
Waiting for container processes to stop...
Killing remaining processes
Container 101: Copying data...
ovztransfer.sh: line 54: 49715 Terminated              vzctl exec $veid "mount -o bind / $tmpdir; tail -f /dev/null > $tmpdir/tmp/lock" > /dev/null 2>&1
Container 101: Setting up destination Container...

Troubleshooting

Container already exists on

This can happen if the transfer was interrupted and did not complete, you need to remove the private directory for the CTID on the target host.

  1. Find the remote VE PRIVATE path, by using grep VE_PRIVATE /etc/vz/vz.conf, or more exactly:
# grep VE_PRIVATE /etc/vz/vz.conf
VE_PRIVATE=/vz/private/$VEID
  1. Check if the target has the directory, eg: /vz/private/<CTID>:
# ls -al /vz/private

If you can see a directory with the CTID, and you're happy to transfer it again, you can delete it and try the transfer process again.

Failed to start Container

This is because the ovztransfer.sh script will try to start the container, if it's already started, the script fails.

# vzctl stop <CTID> 
Stopping container ...
Container was stopped
Container is unmounted

Then try again.

Failed to start destination Container

Try the following command on the target host to find what the problem is:

# vzctl start 201 --wait
Starting Container ...
Mount image: /vz/private/201/root.hdd 
Container is mounted
Setting permissions for image=/vz/private/201/root.hdd
vcmmd: vcmmd_get_ve_config: Failed to connect to VCMMD service
Running quotacheck ...
quotacheck: Unknown quota format: vfsv1
Supported formats are:
  vfsold - original quota format
  vfsv0 - new quota format
  rpc - use RPC calls
  xfs - XFS quota format
Unmount image: /vz/private/201/root.hdd (190)
Container is unmounted
Failed to start the Container

Cause

The error is a combination of issues:

  1. Container configuration file (ve.conf) has deprecated options, it is possible when container was migrated from the older version of OpenVZ.
  2. Container is missing SWAP completely that is necessary to have in OpenVZ 7
  3. The quota format is set to vfsv1 and needs to be vfsold

Resolution

  1. Unset all the memory container parameters:

# vzctl unset $CTID --save --slmmode --vmguarpages --lockedpages --privvmpages --shmpages --physpages --swappages --slmmemorylimit

  1. Set only required amount of memory and swap:

# vzctl set $CTID --save --ram ${SIZE}G --swap ${SIZE}G

  • Note: Where ${SIZE} is a memory in Gigabytes that should be assigned to Container
  1. Remount the container's root filesystem with quota enabled:
vzctl mount $CTID
quotacheck -avugm
vzctl umount $CTID
  1. To disable quotas altogether:
# vzctl set $CTID --quotaugidlimit 0 --save
Mount image: /vz/private/201/root.hdd 
Container is mounted
Failed to unlink /vz/root/201//aquota.user: No such file or directory
Failed to unlink /vz/root/201//aquota.group: No such file or directory
Unmount image: /vz/private/201/root.hdd (190)
Container is unmounted
Saved parameters for Container 201

Quota format not supported in kernel

# vzctl start 201
Starting Container ...
Mount image: /vz/private/201/root.hdd 
Container is mounted
Setting permissions for image=/vz/private/201/root.hdd
Turn userquota on
quotaon: using //aquota.group on /dev/ploop38625p1 [/]: No such process
quotaon: Quota format not supported in kernel.
quotaon: using //aquota.user on /dev/ploop38625p1 [/]: No such process
quotaon: Quota format not supported in kernel.
quotaon exited with error 2
Unmount image: /vz/private/201/root.hdd (190)
Container is unmounted
Failed to start the Container

Convert container to OpenVZ ploop format prior to migration:

# vzctl convert CTID

Also see

Last updated: 2022-02-22

« Go Back

Order now »

all is perfect ;-)