Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
kvm [2010/03/29 23:53] a created |
kvm [2012/04/14 14:25] (current) stojan |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== KVM ====== | ====== KVM ====== | ||
+ | ** | ||
+ | Creating VMs from Debian repositories** | ||
+ | How to create a new VM with 2GB of memory and 15GB disk image directly from Debian repo: | ||
+ | < | ||
+ | virt-install -n vmserver -r 2048 --os-type=linux --os-variant=debiansqueeze \ | ||
+ | --disk / | ||
+ | --vnc --noautoconsole --location | ||
+ | </ | ||
+ | |||
+ | use VNC to connect to the VM console after creating it. | ||
+ | |||
+ | **Some useful commands for handling VMs** | ||
+ | |||
+ | List existing VMs: | ||
+ | < | ||
+ | virsh list | ||
+ | </ | ||
+ | |||
+ | Shutdown an existing VM: | ||
+ | < | ||
+ | virsh shutdown vmname | ||
+ | </ | ||
+ | |||
+ | Destroy (hard shutdown) an existing VM: | ||
+ | < | ||
+ | virsh destroy vmname | ||
+ | </ | ||
+ | |||
+ | Start an existing VM: | ||
+ | < | ||
+ | virsh start vmname | ||
+ | </ | ||
+ | |||
+ | Set the ' | ||
+ | < | ||
+ | virsh autostart vmname | ||
+ | </ | ||
+ | |||
+ | Clone an existing VM. Make sure you update the udev settings after cloning if you want your network to work: | ||
+ | < | ||
+ | virt-clone -o OldVM -n NewVM -f / | ||
+ | </ | ||
+ | |||
+ | Remove a VM from the system ' | ||
+ | < | ||
+ | virsh undefine vmname | ||
+ | </ | ||
+ | |||
+ | **KVM performance boost** | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | < | ||
+ | # grep HUGETLB / | ||
+ | CONFIG_HUGETLBFS=y | ||
+ | CONFIG_HUGETLB_PAGE=y | ||
+ | </ | ||
+ | |||
+ | mkdir /hugepages | ||
+ | |||
+ | Next add an entry to your /etc/fstab so that when you reboot your computer, your hugetlbfs will mount automatically. Your entry should look like the following. | ||
+ | |||
+ | | ||
+ | |||
+ | <note tip> | ||
+ | |||
+ | On x86, large pages are 2MB in size so you need to find out how many 2MB pages you need to back your kvm guest. Let’s say you want to use 512 MB for your guest machine then divide 512 by 2 to get 256 pages. Add a few extra pages for additional memory requirements, | ||
+ | |||
+ | echo 296 > / | ||
+ | |||
+ | If you want this to be a permanent setup , you can also add it to your / | ||
+ | < | ||
+ | # tail -n 5 / | ||
+ | HugePages_Total: | ||
+ | HugePages_Free: | ||
+ | HugePages_Rsvd: | ||
+ | HugePages_Surp: | ||
+ | Hugepagesize: | ||
+ | </ | ||
+ | |||
+ | | ||
+ | |||
+ | You will probably notice a performance increase in your virtual machine. You can check that you’re actually using huge pages by inspecting the / | ||
+ | < | ||
+ | # tail -n 5 / | ||
+ | HugePages_Total: | ||
+ | HugePages_Free: | ||
+ | HugePages_Rsvd: | ||
+ | HugePages_Surp: | ||
+ | Hugepagesize: | ||
+ | </ | ||