wiki:KVM

Version 5 (modified by sky, 9 years ago) (diff)

--

KVM (Kernel-based Virtual Machine)

## VM Remove
virsh undefine test101
virsh undefine test102 --managed-save
virsh undefine test103 --remove-all-storage
rm -f /opt/kvm/test10[1-3].qcow2

## VM Clone
virt-clone --original template --name test101 --file /opt/kvm/test101.qcow2
virt-clone --original template --name test102 --file /opt/kvm/test102.qcow2
virt-clone --original template --name test103 --file /opt/kvm/test103.qcow2

################################################################################

## VM Console & Initialize (CentOS 6)
virsh start test101 && virsh console test101


NNAME=test101
NIP=10.59.72.101

sed -i "/^HOSTNAME/ s/template/$NNAME/" /etc/sysconfig/network
sed -i "/^IPADDR/ s/10.59.72.100/$NIP/" /etc/sysconfig/network-scripts/ifcfg-eth0
cat /dev/null >/etc/udev/rules.d/70-persistent-net.rules
init 6

################################################################################

## VM Console & Initialize (CentOS 7)
virsh start test104 && virsh console test104


NNAME=test104
NIP=10.59.72.104

hostnamectl set-hostname "$NNAME"
sed -i "/^IPADDR/ s/10.59.72.110/$NIP/" /etc/sysconfig/network-scripts/ifcfg-eth0
init 6

################################################################################