wlanboy
Content Contributer
You have a pc that is just doing nothing? You have a dedicated server and want to play around without messing things up?
Enable KVM on your linux kernel to create one/view virtual servers.
Please feel free to add additional steps to this mini guide.
Enable KVM on your linux kernel to create one/view virtual servers.
- Check if your cpu has Intel VT-x or AMD-V
egrep -c '(vmx|svm)' /proc/cpuinfo
1 means that your cpu does have support for hardware virtualization. 0 means you might create quite slow vps. But you are able to run virtual servers. - Check if you have installed a 64bit kernel
Code:uname -m
- Install KVM tools (I am using Ubuntu/Debian commands here)
Code:sudo apt-get install qemu-kvm libvirt-bin bridge-utils
- Add user that runs virtual servers to group (user has to re-login to get new group permissions)
Code:
sudo adduser [username] libvirtd
- Test your installation
Code:virsh -c qemu:///system list Id Name State ----------------------------------
- Fix ownership
Code:sudo chown root:libvirtd /dev/kvm
- Restart kernel modules - or restart the server
Code:rmmod kvm modprobe -a kvm
- Optional: Install GUI for virtual server mangment:
Code:sudo apt-get install virt-manager
- Networking
Well per default KVM has it's own network - called usermode networking. Works like OpenVPN. You have your own subnet - e.g. 10.0.1.0/24 and every KVM gets one ip address out of it.
Enough for me. I once need a connection to one of my webservers out of the KVM. I used port forwarding (iptables) to forward a connection from my host to the KVM.
- Create a virtual server
There are quite a view options. I prefer a python script called "virt-install".
sudo apt-get install python-virtinst
First look to the man page of virt-install
Code:man virt-install
Code:sudo virt-install --connect qemu:///system -n kvm1 -r 2048 --vcpus=2 \ --disk path=/var/lib/libvirt/images/kvm1-image.img,size=20 \ -c /isos/ubuntu-min-install.iso --vnc --noautoconsole --os-type linux \ --accelerate --network=network:default --hvm --vncport=5951
- Managing your virtual servers
A) start managing console
virsh --connect qemu:///system
B) List virtual servers
Code:list -all
Code:start [name of virtual server]
Code:shutdown [name of virtual server]
Please feel free to add additional steps to this mini guide.
Last edited by a moderator: