Difference between revisions of "Cloning VE"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(See also)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
If you need to create an exact copy of an existing VE, these are the steps to make.
 
If you need to create an exact copy of an existing VE, these are the steps to make.
 +
Execute these commands as root.
  
<pre>
+
<source lang="bash">
# OLDVE=222 NEWVE=333 # Just an example
+
OLDVE=222 NEWVE=333 # Just an example
# vzctl stop $OLDVE
+
vzctl stop $OLDVE
# mkdir /vz/root/$NEWVE
+
mkdir /vz/root/$NEWVE
# cp /etc/vz/conf/$OLDVE.conf /etc/vz/conf/$NEWVE.conf
+
cp /etc/vz/conf/$OLDVE.conf /etc/vz/conf/$NEWVE.conf
# cp -a /vz/private/$OLDVE /vz/private/$NEWVE
+
mkdir /vz/private/$NEWVE
# vzctl start $NEWVE; vzctl start $OLDVE
+
pushd /vz/private/$OLDVE; tar c --numeric-owner * | tar x --numeric-owner -C /vz/private/$NEWVE; popd
</pre>
+
nano /etc/vz/conf/$NEWVE.conf # Change the all CTIDs from the old CT to the cloned one. And change the IP.
 +
vzctl start $NEWVE; vzctl start $OLDVE
 +
</source>
 +
 
 +
In case you are making bridge don't forget, before start the VEs, to change host_ifname=veth$OLDVE by  host_ifname=veth$NEWVE in the /etc/vz/conf/$NEWVE.conf file
  
 
== See also ==
 
== See also ==
Line 14: Line 19:
 
The relevant services, particularly when the mySQLd encounters timeout errors, follow the following thread:
 
The relevant services, particularly when the mySQLd encounters timeout errors, follow the following thread:
 
* http://forum.openvz.org/index.php?t=tree&goto=8481&#msg_8481
 
* http://forum.openvz.org/index.php?t=tree&goto=8481&#msg_8481
 +
vzquota : (error)
 +
* http://forum.openvz.org/index.php?t=msg&goto=8928&
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Latest revision as of 10:18, 9 July 2016

If you need to create an exact copy of an existing VE, these are the steps to make. Execute these commands as root.

OLDVE=222 NEWVE=333 # Just an example
vzctl stop $OLDVE
mkdir /vz/root/$NEWVE
cp /etc/vz/conf/$OLDVE.conf /etc/vz/conf/$NEWVE.conf
mkdir /vz/private/$NEWVE
pushd /vz/private/$OLDVE; tar c --numeric-owner * | tar x --numeric-owner -C /vz/private/$NEWVE; popd
nano /etc/vz/conf/$NEWVE.conf # Change the all CTIDs from the old CT to the cloned one. And change the IP.
vzctl start $NEWVE; vzctl start $OLDVE

In case you are making bridge don't forget, before start the VEs, to change host_ifname=veth$OLDVE by host_ifname=veth$NEWVE in the /etc/vz/conf/$NEWVE.conf file

See also[edit]

The relevant services, particularly when the mySQLd encounters timeout errors, follow the following thread:

vzquota : (error)