PDA

View Full Version : How to change an OpenVZ VPS/VM/CT id/number?



Fli
03-14-2015, 08:05 PM
How we can change an id number of any OpenVZ VPS/VM/CT?

OLDID: 1800
NEWID: 9990

------ SHORT STORY -------
do commands (even if VPS/s are stopped - chkpnt will do nothing):

vzctl chkpnt 1800 --dumpfile /tmp/Dump.1800
mv /vz/private/1800 /vz/private/9990;mv /vz/root/1800 /vz/root/9990;mv /etc/vz/conf/1800.conf /etc/vz/conf/9990.conf
vzctl restore 9990 --dumpfile /tmp/Dump.1800
it will dump VM and stop it, then we rename folders and files of old VM and restore dump and result is running VM

------ LONG STORY -------

One need to create an checkpoint of a VPS


vzctl chkpnt 1800 --dumpfile /tmp/dump.1800


Setting up checkpoint...
suspend...
dump...
kill...
Checkpointing completed successfully
Unmounting file system at /vz/root/1800
Unmounting device /dev/ploop26411
Container is unmounted

VPS is shutdown and we can then rename folder names of the VPS and rename VPS config file:


mv /vz/private/1800 /vz/private/9990
mv /vz/root/1800 /vz/root/9990
mv /etc/vz/conf/1800.conf /etc/vz/conf/9990.conf

Then restore checkpoint dump file:


vzctl restore 9990 --dumpfile /tmp/Dump.1800


Restoring container ...Opening delta /vz/private/9990/root.hdd/root.hdd
Adding delta dev=/dev/ploop26411 img=/vz/private/9990/root.hdd/root.hdd (rw)
Mounting /dev/ploop26411p1 at /vz/root/9990 fstype=ext4 data='balloon_ino=12,usrjquota=aquota.user,grpjquo ta=aquota.group,jqfmt=vfsv0,'
Container is mounted
undump...
Adding IP address(es): x.x.x.x
Setting CPU limit: 100
Setting CPU units: 1000
Setting CPUs: 1
resume...
Container start in progress...
Restoring completed successfully

the result is running VPS with new ID