Differences between revisions 2 and 3
Revision 2 as of 2017-10-12 22:54:07
Size: 1048
Editor: shran
Comment:
Revision 3 as of 2017-10-12 22:54:27
Size: 1042
Editor: shran
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
Line 10: Line 9:
Line 16: Line 14:

Domain Cloning

Once a template system has been installed, that system can be cloned. Use the following script to clone your template

clonedomain.sh

   1 #!/bin/sh
   2 LVM_GROUP="vg2"
   3 NAME_ORIGINAL="stretch-template"
   4 LVM_NAME_ORIGINAL="kvm_${NAME_ORIGINAL}_vda"
   5 LVM_SIZE_ORIGINAL=`lvs /dev/${LVM_GROUP}/${LVM_NAME_ORIGINAL} -o LV_SIZE --noheadings --units B --nosuffix`
   6 NAME_CLONE="stretch-clone"
   7 LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
   8 
   9 if [ $# -eq 0 ]
  10 then
  11         echo "${0}: domain-name"
  12 else
  13         NAME_CLONE=${1}
  14         LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
  15 fi
  16 
  17 if [ ! -e /dev/${LVM_GROUP}/${LVM_NAME_CLONE} ]
  18 then
  19         # create lvm partition
  20         lvcreate --size ${LVM_SIZE_ORIGINAL}B --name ${LVM_NAME_CLONE} ${LVM_GROUP}
  21 
  22         # clone the domain
  23         virt-clone --original ${NAME_ORIGINAL} --name ${NAME_CLONE} --file /dev/${LVM_GROUP}/${LVM_NAME_CLONE} --check path_in_use=off,path_exists=off
  24 else
  25         echo "${0}: refusing to overwrite existing domain"
  26 fi

None: Domain Cloning (last edited 2021-12-31 14:57:50 by Kristian Kallenberg)