Kvm: Difference between revisions

From Halfface
Jump to navigation Jump to search
No edit summary
Line 42: Line 42:
  virsh dumpxml fedora_20_raid1 | less
  virsh dumpxml fedora_20_raid1 | less
==disk handling==
==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


# Attach disk
# Attach disk
  virsh attach-disk fedora_20_raid1 /ssd/libvirt/fedora20_1.qcow2 vda --sourcetype file --subdriver qcow2
  virsh attach-disk fedora_20_raid1 /ssd/libvirt/fedora20_1.qcow2 vda --sourcetype file --subdriver qcow2


# Copy kvm machine.
# Copy kvm machine.
  virsh dumpxml <domain> > domain.xml
  virsh dumpxml <domain> > domain.xml
  vi domain.xml
  vi domain.xml
  virsh create domain.xml
  virsh create domain.xml


# Eject cdrom.
virsh change-media www.halfface.se hda --eject


[[Category:Applications]]
[[Category:Applications]]
[[Category:Unix]]
[[Category:Unix]]
[[Category:Virtualization]]
[[Category:Virtualization]]

Revision as of 20:16, 11 March 2014

prepare environment

Is environment prepared for viritutalization.

egrep '(vmx|svm)' /proc/cpuinfo

vmx - (intel) svm - (amd)

Create disk image.

qemu-img create -f qcow2 f8_1_x86_64.img 10G

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

connect to virtual machine.

virt-viewer Fedora_16

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

list information

  1. Simple information about domain.
virsh dominfo fedora_20_raid1
  1. View information about domain.
virsh dumpxml fedora_20_raid1 | less

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