Skip to content

Latest commit

 

History

History
193 lines (136 loc) · 2.43 KB

kvm.md

File metadata and controls

193 lines (136 loc) · 2.43 KB

KVM Virtualization

GUI

SSH to server with X Forwarding:

ssh -X kvmhost01

Send GUI program back to your local desktop:

sudo su
cp -a .Xauthority /root/
unset XAUTHORITY
virt-manager

CLI

KVM Virsh can manage virtual machines on the command line

virsh
man virsh
virsh connect qemu:///system    # connects to daemon supervising Qemu or KVM domains
virsh list

to view details about a machine:

virsh dumpxml machinename
virsh dumpxml machinename > /tmp/machine.xml
virsh dominfo <num|name>
virsh dominfo ipa01

copy/edit /tmp/machine.xml to create a new machine:

virsh create /tmp/machine.xml

or to define the machine but not run it:

virsh define /tmp/machine_new.xml
virsh start foo
virsh reboot foo
virsh shutdown foo
virsh suspend foo
virsh resume foo
virsh destroy machinename
virsh undefine machinename
yum install @virtualization
##yum install kvm kmod-kvm qemu
#yum install virsh
#apt-get install virsh
kvm --help
kvm -m 512 -hda disk.img -cdrom ubuntu.iso -boot d -smp 2
qemu-kvm --help
modprobe -l | grep kvm

convert VMware disk image (not tested this):

kvm-img convert -O qcow2 zimbra-000001.vmdk zimbra.qcow2

File Sharing with KVM Host

in KVM host:

/usr/bin/qemu-kvm -m 1024 -name f15 -drive file=/images/f15.img,if=virtio -fsdev local,security_model=passthrough,id=fsdev0,path=/tmp/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare

in VM:

mount -t 9p -o trans=virtio,version=9p2000.L /hostshare /tmp/host_files

Console

virsh ttyconsole 12

add one if not existing:

virsh edit 12
virsh console 12 # opens serial console of server

no output problem guest hasn't been configured to support console

in guest:

cp /etc/init/tty1.conf /etc/init/ttyS0.conf

edit:

exec /sbin/getty -8 115200 ttyS0 xterm
vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"
update-grub2

then restart guest.

Ported from private Knowledge Base pages 2010+