1508
Comment:
|
1652
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
Once a template system has been installed, that system can be cloned. `virt-clone` will automatically change the MAC address of your network device. | |
Line 3: | Line 4: |
Once a template system has been installed, that system can be cloned. `virt-clone` will automatically change the MAC address of your network device. Use the script below to clone your template. | == Cloning == Use the script below to clone your template. |
Line 5: | Line 7: |
`clonedomain.sh` | `domain_clone.sh` |
Line 34: | Line 36: |
Make a clone | Make a clone. |
Line 36: | Line 38: |
./clonedomain.sh clone | ./domain_clone.sh clone |
Line 39: | Line 41: |
== Cleaning up Your New Guest == | == Console Access == Remove console access by [[Domain Editing|editing the domain]]. |
Line 41: | Line 44: |
Find the blocksize and the partition layout for the guest {{{ fdisk -ul /dev/vg2/kvm_clone_vda }}} |
== Memory == Increase or decrease amount of memory by [[Domain Editing|editing the domain]]. |
Line 46: | Line 47: |
Calculate the partition offset. Offset = sector * blocksize. In this case 512 * 499712 = 255852544. mount the partition. {{{ mount -o loop,offset=255852544 /dev/vg2/kvm_clone_vda /mnt/misc }}} |
== Network == For your convenience add the MAC address to the DHCP servers lits of fixed IP-adresses before starting the system for the first time. This way you know beforehand which IP-address to connect to. |
Line 51: | Line 50: |
change the hostname delete ssh keys |
== Guest OS == Continue by configuring the [[KVM Guest Operating System|KVM Guest Operating System]]. |
Domain Cloning
Once a template system has been installed, that system can be cloned. virt-clone will automatically change the MAC address of your network device.
Cloning
Use the script below to clone your template.
domain_clone.sh
1 #!/bin/sh
2
3 LVM_GROUP="vg2"
4 NAME_ORIGINAL="stretch-template"
5 LVM_NAME_ORIGINAL="kvm_${NAME_ORIGINAL}_vda"
6 LVM_SIZE_ORIGINAL=`lvs /dev/${LVM_GROUP}/${LVM_NAME_ORIGINAL} -o LV_SIZE --noheadings --units B --nosuffix`
7 NAME_CLONE="stretch-clone"
8 LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
9
10 if [ $# -gt 0 ]
11 then
12 NAME_CLONE=${1}
13 LVM_NAME_CLONE="kvm_${NAME_CLONE}_vda"
14 fi
15
16 if [ ! -e /dev/${LVM_GROUP}/${LVM_NAME_CLONE} ]
17 then
18 # create lvm partition
19 lvcreate --size ${LVM_SIZE_ORIGINAL}B --name ${LVM_NAME_CLONE} ${LVM_GROUP}
20
21 # clone the domain
22 virt-clone --original ${NAME_ORIGINAL} --name ${NAME_CLONE} --file /dev/${LVM_GROUP}/${LVM_NAME_CLONE} --check path_in_use=off,path_exists=off
23 else
24 echo "${0}: refusing to overwrite existing domain"
25 fi
Make a clone.
./domain_clone.sh clone
Console Access
Remove console access by editing the domain.
Memory
Increase or decrease amount of memory by editing the domain.
Network
For your convenience add the MAC address to the DHCP servers lits of fixed IP-adresses before starting the system for the first time. This way you know beforehand which IP-address to connect to.
Guest OS
Continue by configuring the KVM Guest Operating System.