john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Kvm create virt clone install centos6 edit ram

OPTIONAL

vi /etc/selinux/config SELINUX=disabled # make things easy on yourself

reboot


INSTALL

egrep '(vmx|svm)' --color=always /proc/cpuinfo # will produce lots of output if the cpu supports hardware virtualiztion

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* # necessary?

yum install kvm libvirt python-virtinst qemu-kvm

/etc/init.d/libvirtd start # start the libvirt daemon

virsh --help # can be run in interactive mode with virsh -c qemu:///system

virsh -V # version

virsh -c qemu:///system list --all # -c is short for --connect, list the vm's

virsh list --all # seems equivalent to the above?

Id Name State

1 centbase01 running


NETWORKING

yum install bridge-utils

vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE="br0" NM_CONTROLLED="yes" ONBOOT=yes TYPE=Bridge BOOTPROTO=none IPADDR=192.168.0.100 PREFIX=24 GATEWAY=192.168.0.1 DNS1=8.8.8.8 DNS2=8.8.4.4 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System br0"

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"

BOOTPROTO=none

NM_CONTROLLED="yes" ONBOOT=yes TYPE="Ethernet" UUID="73cb0b12-1f42-49b0-ad69-731e888276ff" HWADDR=00:1E:90:F3:F0:02

IPADDR=192.168.0.100

PREFIX=24

GATEWAY=192.168.0.1

DNS1=8.8.8.8

DNS2=8.8.4.4

DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" BRIDGE=br0

/etc/init.d/network force-reload

ifconfig # verify the new bridge is attached to eth0


GUEST OS

virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 --disk path=/var/lib/libvirt/images/vm10.img,size=12 -c /dev/cdrom --vnc --noautoconsole --os-type linux --os-variant debiansqueeze --accelerate --network=bridge:br0 --hvm

Of course, you can also create an ISO image of the Debian Squeeze Netinstall CD (please create it in the /var/lib/libvirt/images/ directory because later on I will show how to create virtual machines through virt-manager from your Fedora desktop, and virt-manager will look for ISO images in the /var/lib/libvirt/images/ directory)...

dd if=/dev/cdrom of=/var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso

... and use the ISO image in the virt-install command:

virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 --disk path=/var/lib/libvirt/images/vm10.img,size=12 -c /var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant debiansqueeze --accelerate --network=bridge:br0 --hvm

Starting install... Allocating 'vm10.img' | 12 GB 00:00 Creating domain... | 0 B 00:00 Domain installation still in progress. You can reconnect to the console to complete the installation process.

virsh --connect qemu:///system suspend centbase01 # long format of the commands virsh resume centbase01 virsh shutdown centbase01 # graceful shutdown

virsh destroy centbase01 # force shutdown

virsh start centbase01

virsh dominfo centbase01 # show info for that guest

virsh create xml_file.xml # create using an xml definition virsh dumpxml centbase01 > centbase01.xml # get the xml definition (i.e. save the definition as a backup) virsh edit centbase01 # i.e. upgrade RAM 1048576 to 4194304 (4GB)

virsh undefine centbase01 # remove the definition but not the image file # to DELETE you must undefine, then manually remove the storage (rm /var/lib/libvirt/images/filename.img)

virsh save centbase01 my_state_file # save a guest's state virsh restore centbase01 my_state_file # restore a guest's state from a file


GUEST MANAGEMENT

for gui maanagement: yum install virt-manager libvirt qemu-system-x86 openssh-askpass

virt-manager

FOR CONSOLE ACCESS

vi /boot/grub/grub.conf # inside of the Guest enable kvm console access via serial port

kernel= ... console=tty0 console=ttyS0,115200n8 # append to the end of the kernel line reboot

virsh console centbase01
Connected to domain centbase01 # press enter once to see the login prompt Escape character is ^] # Control+] to exit the virsh console

more info including Windows Guest: http://kirkkosinski.com/2013/01/configuring-centos-6-and-windows-vms-for-virsh-console-on-kvm/


CLONING A GUEST VM virt-clone --version virt-clone --help virt-clone --connect=qemu:///system -o centbase01 -n centbase02 -f /var/lib/libvirt/images/centbase02.img

diff /etc/libvirt/qemu/centbase01.xml /etc/libvirt/qemu/centbase02.xml

SOLUTION TO NO NETWORK IN KVM GUEST AFTER VIRT-CLONE

rm /etc/udev/rules.d/70-persistent-net.rules

vi /etc/sysconfig/network-scripts/ifcfg-eth0 # ubuntu is /etc/network/interfaces but rarely has MAC

either remove the HW line OR use virsh dumpxml mynewclone to see what was assigned by virt-clone and change it

reboot (or virsh shutdown mynewclone , then virsh start mynewclone)

Further Reading on Cloning: http://www.dedoimedo.com/computers/kvm-clone.html


  • « file replace string
  • Centos6 3 minimal secure server »

Published

Feb 12, 2013

Category

virtualization

~523 words

Tags

  • centos6 4
  • clone 2
  • create 14
  • edit 3
  • install 58
  • kvm 1
  • ram 3
  • virt 1
  • virtualization 87