Header Ads

Header Ads

Creating VPS using Debian and Qemu

Hi, today i will write simple tutorial about VPS (virtual private server) management and creation on GNU/Debian Linux. We will use full virtualization. In computer science, full virtualization is a virtualization technique used to provide a certain kind of virtual machine environment, namely, one that is a complete simulation of the underlying hardware. Full virtualization requires that every salient feature of the hardware be reflected into one of several virtual machines – including the full instruction set, input/output operations, interrupts, memory access, and whatever other elements are used by the software that runs on the bare machine, and that is intended to run in a virtual machine. In such an environment, any software capable of execution on the raw hardware can be run in the virtual machine and, in particular, any operating systems. The obvious test of virtualization is whether an operating system intended for stand-alone use can successfully run inside a virtual machine.

apt-get install qemu-kvm libvirt-bin virtinst

Prepare network bridge, asumes that your main ISP network line is connected to eth0, edit "/etc/network/interfaces" you should see, something like this:
allow-hotplug eth0
iface eth0 inet dhcp
Comment these lines with #, and add these lines to the config:
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_maxwait 0
bridge_fd 0
Save file and open /etc/sysctl.conf, then put these lines at the end:
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
Save config, and now open /etc/rc.local, and then put these lines before "exit 0":
/sbin/sysctl -p /etc/sysctl.conf
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
In my situation, i used these settings to create full FreeBSD virtualized VPS
# mkdir /var/kvm/images/
Here you can choose allocate all space with hdd image or make sparse image (sparse image will be much slower than  fully allocated one)
# fallocate -l 50192M /var/kvm/images/freebsd.img
or sparse image
# truncate --size=50192M /var/kvm/images/freebsd.img
# virt-install --force -r 768 -n FreeBSD \
#  -f /var/kvm/images/freebsd.img \
#  --bridge=br0,model=rtl8139,mac=52:54:00:93:94:97 \
#  --vnc --vnclisten= --vncport=5913 \
#  --cdrom /var/kvm/FreeBSD-9.2-RC3-i386-disc1.iso
It will automatically start, and now you can connect using VNC client to yourip:5913, and configure/install operating system.

Some commands managing VPSs:
# virsh --connect qemu:///system  # -- connect to the virsh management console
# shutdown vps_name # -- gracefully shutdown vps
# destroy vps_name # -- hard shutdown (power off)
# vncdisplay vps_name # -- shows how to configured vnc server
# nodeinfo # -- information
# list # -- lists all vps'es
Good day!

No comments:

Copyright (c) 2012-2013 Unix Master. Powered by Blogger.