Posts Tagged ‘KVM’

Ubuntu Virtual Machine(KVM) Notes

02 6月
virt-manger : start the VM manager panel. need ssh -X. virsh: almost all operations with the VM. details see --help.   How to clone a VM: sudo virt-clone --original [original vm id] --name [new vm id] -f /data/virtual/var/lib/libvirt/images/[new vm img file name] After cloned, login to the new guest machine and change its hostname, ip add info, etc. For Ubuntu guest machine: vim /etc/udev/rules.d/70-persistent-net.rules Remove the eth0 which should be cloned from the original one and modify the other eth1 to eth0. sed -i "s/[original host name]/[new host name]/g" `grep [original host name] -rl /etc/ssh/ /etc/hosts /etc/hostname` vim /etc/network/interfaces auto eth0 iface eth0 inet static address 192.168.1.X netmask network broadcast gateway   For CentOS guest machine: use 'setup' to config the network and host name. and: rm /etc/sysconfig/networking/devices/ifcfg-eth0.bak /etc/sysconfig/networking/profiles/default/ifcfg-eth0.bak /etc/sysconfig/network-scripts/ifcfg-eth0.bak   How to Rename a VM: Shutdown the VM. sudo virsh dumpxml [original id] > [new id].xml vim [new id].xml and modify all the original id in the xml to the new one. sudo virsh undefine [original id] goto the image folder and change the original img name to the new one. sudo virsh define [new id].xml Done.