Difference between revisions of "Cloning ploop containers"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(created)
 
(added category)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
This describes a non-official and unsupported method of cloning ploop containers. It uses shared base ploop delta (this configuration is not officially supported but apparently works just fine).
 
This describes a non-official and unsupported method of cloning ploop containers. It uses shared base ploop delta (this configuration is not officially supported but apparently works just fine).
  
This method lets you very quickly create thousands of identical containers. This might be useful for example in testing.
+
This method lets you very quickly create thousands of identical containers, saving a lot of disk space as well. This might be useful for example in testing, but should not be used in production.
  
 
== Legacy OpenVZ ==
 
== Legacy OpenVZ ==
Line 34: Line 34:
 
# Need to run <code>vzpkg</code> instead of <code>vztmpl-dl</code>
 
# Need to run <code>vzpkg</code> instead of <code>vztmpl-dl</code>
 
# Need to remove <code>VEID=</code> line from the "donor" config file
 
# Need to remove <code>VEID=</code> line from the "donor" config file
# Need to copy <code>.ve.layout</code> from the donor private area
+
# Need to copy <code>.ve.layout</code> from the donor private area#
 +
# Base delta name is <code>root.hds</code> not <code>root.hdd</code>
  
 
<source lang="bash">
 
<source lang="bash">
Line 52: Line 53:
 
for CT in $(seq 1000 2000); do \
 
for CT in $(seq 1000 2000); do \
 
       mkdir -p /vz/private/$CT/root.hdd /vz/root/$CT; \
 
       mkdir -p /vz/private/$CT/root.hdd /vz/root/$CT; \
       ln /vz/private/$SRCID/root.hdd/root.hdd /vz/private/$CT/root.hdd/root.hdd; \
+
       ln /vz/private/$SRCID/root.hdd/root.hds /vz/private/$CT/root.hdd/root.hds; \
 
       cp -nr /vz/private/$SRCID/root.hdd /vz/private/$CT/; \
 
       cp -nr /vz/private/$SRCID/root.hdd /vz/private/$CT/; \
 
       cp /etc/vz/conf/$SRCID.conf /etc/vz/conf/$CT.conf; \
 
       cp /etc/vz/conf/$SRCID.conf /etc/vz/conf/$CT.conf; \
 
       cp -a /vz/private/50/.ve.layout /vz/private/$CT/; \
 
       cp -a /vz/private/50/.ve.layout /vz/private/$CT/; \
 
done
 
done
 +
 +
vzctl set $SRCID --disabled yes --save # make sure we don't use it
 
</source>
 
</source>
 +
 +
[[Category: Storage]]

Latest revision as of 10:35, 1 September 2015

This describes a non-official and unsupported method of cloning ploop containers. It uses shared base ploop delta (this configuration is not officially supported but apparently works just fine).

This method lets you very quickly create thousands of identical containers, saving a lot of disk space as well. This might be useful for example in testing, but should not be used in production.

Legacy OpenVZ[edit]

SRCID=50 # "Donor" container ID
TMPL=centos-6-x86_64 # Template to use

vztmpl-dl $TMPL # make sure we use the latest one
vzctl create $SRCID --ostemplate $TMPL

vzctl mount $SRCID
while killall -0 ext4lazyinit; do sleep 1; done
vzctl umount $SRCID

vzctl snapshot $SRCID

for CT in $(seq 1000 2000); do \
       mkdir -p /vz/private/$CT/root.hdd /vz/root/$CT; \
       ln /vz/private/$SRCID/root.hdd/root.hdd /vz/private/$CT/root.hdd/root.hdd; \
       cp -nr /vz/private/$SRCID/root.hdd /vz/private/$CT/; \
       cp /etc/vz/conf/$SRCID.conf /etc/vz/conf/$CT.conf; \
done

vzctl set $SRCID --disabled yes --save # make sure we don't use it

VZ7[edit]

The differences from the above script are:

  1. Need to run vzpkg instead of vztmpl-dl
  2. Need to remove VEID= line from the "donor" config file
  3. Need to copy .ve.layout from the donor private area#
  4. Base delta name is root.hds not root.hdd
SRCID=50 # "Donor" container ID
TMPL=centos-6-x86_64 # Template to use

vzpkg update cache $TMPL # make sure we use the latest one
vzctl create $SRCID --ostemplate $TMPL
vzctl mount $SRCID
while killall -0 ext4lazyinit; do sleep 1; done
vzctl umount $SRCID

vzctl snapshot $SRCID

sed -ie '/^VEID=/d' /etc/vz/conf/$SRCID.conf

for CT in $(seq 1000 2000); do \
       mkdir -p /vz/private/$CT/root.hdd /vz/root/$CT; \
       ln /vz/private/$SRCID/root.hdd/root.hds /vz/private/$CT/root.hdd/root.hds; \
       cp -nr /vz/private/$SRCID/root.hdd /vz/private/$CT/; \
       cp /etc/vz/conf/$SRCID.conf /etc/vz/conf/$CT.conf; \
       cp -a /vz/private/50/.ve.layout /vz/private/$CT/; \
done

vzctl set $SRCID --disabled yes --save # make sure we don't use it