⇤ ← Revision 1 as of 2017-10-12 22:50:14
1032
Comment:
|
1048
|
Deletions are marked like this. | Additions are marked like this. |
Line 6: | Line 6: |
{{{ | {{{#!highlight bash |
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
3 LVM_GROUP="vg2"
4
5 NAME_ORIGINAL="stretch-template"
6 LVM_NAME_ORIGINAL="kvm_${NAME_ORIGINAL}_vda"
7 LVM_SIZE_ORIGINAL=`lvs /dev/${LVM_GROUP}/${LVM_NAME_ORIGINAL} -o LV_SIZE --noheadings --units B --nosuffix`
8 NAME_CLONE="stretch-clone"
9 LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
10
11
12 if [ $# -eq 0 ]
13 then
14 echo "${0}: domain-name"
15 else
16 NAME_CLONE=${1}
17 LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
18 fi
19
20 if [ ! -e /dev/${LVM_GROUP}/${LVM_NAME_CLONE} ]
21 then
22 # create lvm partition
23 lvcreate --size ${LVM_SIZE_ORIGINAL}B --name ${LVM_NAME_CLONE} ${LVM_GROUP}
24
25 # clone the domain
26 virt-clone --original ${NAME_ORIGINAL} --name ${NAME_CLONE} --file /dev/${LVM_GROUP}/${LVM_NAME_CLONE} --check path_in_use=off,path_exists=off
27 else
28 echo "${0}: refusing to overwrite existing domain"
29 fi