Kvm: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
=prepare environment= | |||
# Is environment prepared for viritutalization. | # Is environment prepared for viritutalization. | ||
egrep '(vmx|svm)' /proc/cpuinfo | egrep '(vmx|svm)' /proc/cpuinfo | ||
vmx - (intel) svm - (amd) | vmx - (intel) svm - (amd) | ||
=Create disk image.= | |||
qemu-img create -f qcow2 fedora20.halfface.se.qcow2 50G | qemu-img create -f qcow2 fedora20.halfface.se.qcow2 50G | ||
Line 10: | Line 10: | ||
yum install -y qemu kvm SDL bridge-utils tunctl | yum install -y qemu kvm SDL bridge-utils tunctl | ||
=install virtual machine.= | |||
virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm | virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm | ||
=delete virtual machine.= | |||
virsh undefine kvm_1 | virsh undefine kvm_1 | ||
=list libvirt storage pools= | =list libvirt storage pools= | ||
virsh pool-list --all | virsh pool-list --all | ||
=connect to virtual machine.= | |||
virt-viewer Fedora_16 | virt-viewer Fedora_16 | ||
On remote machine over ssh | On remote machine over ssh | ||
virt-viewer --connect qemu+ssh://root@anden.se2.ipsoft.com/system win8 | virt-viewer --connect qemu+ssh://root@anden.se2.ipsoft.com/system win8 | ||
=convert file format= | |||
# img to qcow2 | # img to qcow2 | ||
qemu-img convert -cp -O qcow2 kvm_1.img kvm_1.qcow2 | qemu-img convert -cp -O qcow2 kvm_1.img kvm_1.qcow2 | ||
Line 28: | Line 28: | ||
qemu-img convert disk0.vmdk -O qcow2 bigbluebutton.qcow2 | qemu-img convert disk0.vmdk -O qcow2 bigbluebutton.qcow2 | ||
=snapshot= | |||
# Create snapshot | # Create snapshot | ||
virsh snapshot-create SL_63 | virsh snapshot-create SL_63 | ||
Line 39: | Line 39: | ||
virsh snapshot-revert fedora20_2.halfface.se 1414336149 | virsh snapshot-revert fedora20_2.halfface.se 1414336149 | ||
=list information= | |||
# Simple information about domain. | # Simple information about domain. | ||
virsh dominfo fedora_20_raid1 | virsh dominfo fedora_20_raid1 | ||
Line 48: | Line 48: | ||
virsh autostart virtual_machine_name | virsh autostart virtual_machine_name | ||
=disk handling= | |||
# Detach one of the disks. | # Detach one of the disks. | ||
virsh detach-disk fedora_20_raid1 vda | virsh detach-disk fedora_20_raid1 vda | ||
Line 63: | Line 63: | ||
virsh change-media www.halfface.se hda --eject | virsh change-media www.halfface.se hda --eject | ||
=duplicate move machine= | |||
# You cannot "clone" a running vm, stop it. suspend and destroy | # You cannot "clone" a running vm, stop it. suspend and destroy | ||
# are also valid options for less graceful cloning | # are also valid options for less graceful cloning |
Revision as of 14:46, 18 December 2016
prepare environment
# Is environment prepared for viritutalization. egrep '(vmx|svm)' /proc/cpuinfo vmx - (intel) svm - (amd)
Create disk image.
qemu-img create -f qcow2 fedora20.halfface.se.qcow2 50G
# Install software. yum install -y qemu kvm SDL bridge-utils tunctl
install virtual machine.
virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm
delete virtual machine.
virsh undefine kvm_1
list libvirt storage pools
virsh pool-list --all
connect to virtual machine.
virt-viewer Fedora_16
On remote machine over ssh
virt-viewer --connect qemu+ssh://root@anden.se2.ipsoft.com/system win8
convert file format
# img to qcow2 qemu-img convert -cp -O qcow2 kvm_1.img kvm_1.qcow2 # vmdk to qcow2 qemu-img convert disk0.vmdk -O qcow2 bigbluebutton.qcow2
snapshot
# Create snapshot virsh snapshot-create SL_63 # List snapshots virsh snapshot-list SL_63 # Delete snapshot virsh snapshot-delete SL_63 1346734871 # Revert to snapshot snapshot-revert virsh snapshot-revert fedora20_2.halfface.se 1414336149
list information
# Simple information about domain. virsh dominfo fedora_20_raid1
# View information about domain. virsh dumpxml fedora_20_raid1 | less
change value of virtual machine
virsh autostart virtual_machine_name
disk handling
# Detach one of the disks. virsh detach-disk fedora_20_raid1 vda
# Attach disk virsh attach-disk fedora_20_raid1 /ssd/libvirt/fedora20_1.qcow2 vda --sourcetype file --subdriver qcow2
# Copy kvm machine. virsh dumpxml <domain> > domain.xml vi domain.xml virsh create domain.xml
# Eject cdrom. virsh change-media www.halfface.se hda --eject
duplicate move machine
# You cannot "clone" a running vm, stop it. suspend and destroy # are also valid options for less graceful cloning virsh shutdown this.vm # copy the storage. cp /var/lib/libvirt/images/{this-vm,that-vm}.img # dump the xml for the original virsh dumpxml this-vm > /tmp/that-vm.xml # hardware addresses need to be removed, libvirt will assign # new addresses automatically sed -i /uuid/d /tmp/that-vm.xml sed -i '/mac address/d' /tmp/that-vm.xml # and actually rename the vm: (this also updates the storage path) sed -i s/this-vm/that-vm /tmp/that-vm.xml # finally, create the new vm virsh define /tmp/that-vm.xml virsh start this-vm virsh start that-vm
virt-convert
Convert vmware image to kvm.
virt-convert . --disk-format qcow2 --destination .
drivers
Drivers for other os and enhancements.
https://www.spice-space.org/download.html
access via spice
remote-viewer spice://10.151.105.122:5900