Virtualization

How to Change Container ID in OpenVZ

change-container-id-openvz
mm
Written by Santosh Prasad

OpenVZ is a virtualization technology for Linux. In OpenVZ containers also known as Virtual Machine or VPS. Containers share the resources of the physical machine. Means a particular amount of Disk space and RAM will not be allocated to any particular VPS (Container). Resources pool equally shared by all Containers on demand.

In this article I will show how you can change the ID of an OpenVZ container.

Method #1 : Create Checkpoint and Rename Container ID

Use a checkpoint and rename the container directories on the shell, In this tutorial I am going to change ID of a container from 101 to 102.

Creating Checkpoint of The VM

# vzctl chkpnt 101 --dumpfile /tmp/ovz-101.dump

Rename The Files of the Container

# mv /etc/vz/conf/101.conf /etc/vz/conf/102.conf
# mv /vz/private/101 /vz/private/102
# mv /vz/root/101 /vz/root/102

Restore Checkpoint

Finally restore the checkpoint using below command.

# vzctl restore 102 --dumpfile /tmp/ovz-101.dump

Method #2 : Using vzdump Command

Alternatively you use the vzdump command to create a backup and restore it with vzrestore command under new container ID.

# mkdir /home/backup
# chmod 700 /home/backup
# chown root:root /home/backup

Container Backup

Now backup the container with ID 101.

# vzdump --compress --dumpdir /home/backup 101

Restore Backup

Now restore the container with ID 102.

# vzrestore /home/backup/vzdump-101.tgz 102

Now shutdown container 101 and start 102 using below command.

# vzctl stop 101
# vzctl start 102

Test your container 102 is fully working if everything looks file then delete container 101.

# vzctl destroy 101
Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment