Network System Access Solutions

User Tools

Site Tools





Bind vnc to virutal maschine.


Connect to virtual maschine.

vncviewer -via IP_OF_KVM_HOST

Show guests’ information:

Show a list of all the defined guests:

virsh list --all

Show a guest’s info:

virsh dominfo guest's_name

Start and stop guests:

Start a guest:

virsh start guest's_name

Shutdown a guest (gently):

virsh shutdown guest's_name

Shutdown a guest (wild):

virsh destroy guest's_name

Suspend a guest:

virsh suspend guest's_name

Resume a suspended guest:

virsh resume guest's_name

Create and modify guests:

Create a new guest Create a guest from its XML definition:

virsh create xml_file.xml

Dump a guest’s definition in XML:

virsh dumpxml guest's_name

Modify a guest’s definition:

virsh edit guest's_name

Remove a guest’s definition (it doesn’t remove the image file):

virsh undefine guest's_name

Backup and restore guests:

Save a guest’s state on a file:

virsh save guest's_name guest's_state_file

Restore a guest from a state file:

virsh restore guest's_state_file

Mounting qcow2 Images

modprobe nbd max_part=63

Connecting a logic device

qemu-nbd -c /dev/nbd0 imagefile

Checking for partions on logic device

fdisk -l /dev/nbd0

Mounting partion

mount /dev/nbd0p1 /mnt

Umounting and Disconnecting the logic device

umount /mnt && qemu-nbd -d /dev/nbd0

Creating a new VM

cp -av /home/root/kvm/skelserver /home/root/kvm/servername
vi /home/root/kvm/servername/run.sh     # Change here the Filenname 
cp -av /etc/libvirt/qemu/skelserver.xml /etc/libvirt/qemu/servername.xml     # change here Mac, UUID, FILE and NAME
service libvirt-bin reload   

Start block device

kvm -vga std -m 512 -hda /dev/sda1 -boot d

Boot from cd

kvm -vga std -m 512 -hda /dev/sda1 -cdrom fixntldr.iso -boot d

Convert images

qemu-img convert -c -O qcow2 /path/to/shrinked_image.raw /path/to/shrinked_image.qcow2

Resize images

qemu-img resize win7.img +20GB

Install via virt-install

virt-install -n mail05 -r 2048 --os-type=linux --os-variant=debiansqueeze --disk /var/lib/libvirt/images/mail05.qcow2,device=disk,bus=virtio,size=8,sparse=true,format=qcow2 -w network=vnet3,model=virtio --vnc --noautoconsole --location http://mirror.hetzner.de/debian/packages/dists/stable/main/installer-amd64/
virt-install --connect qemu+ssh://root@sulkvm01.intern.local/system --accelerate --hvm --network bridge=br30,model=virtio --graphics vnc --vcpus=10 --ram=1024 --os-type=linux -l http://ftp.halifax.rwth-aachen.de/ubuntu/dists/precise/main/installer-amd64 -x "ks=http://monit.intern.local/ks/ubuntu.cfg ksdevice=eth0 dns=" --disk path=/var/lib/libvirt/images/testvm4.qcow2,size=10,format=qcow2 --noautoconsole --name=testvm4
linux/kvm.txt · Last modified: 2013/06/13 10:32 by michel.pelzer