Linux-Vserver on Debian Sarge
Summary
Linux-VServer allows you to create virtual private servers and security contexts which operate like a normal Linux server, but allow many independent servers to be run simultaneously in one box at full speed. All services, such as ssh, mail, Web, and databases, can be started on such a VPS, without modification, just like on any real server. Each virtual server has its own user account database and root password and doesn't interfere with other virtual servers.
PreparationStart out with a fresh install of Debian Sarge 3.1. It is recommended to keep the host system as minimal as possible (I rarely see any reason to run any more than SSH and iptables).
Packages to installAlways update your apt database before installing software, and upgrade current packages: # apt-get update && apt-get upgrade
# apt-get install util-vserver ssh ncurses-base libncurses5-dev
The Files
The KernelPlease that I have not done this section "The Debian Way". Everything was done using a Vanilla kernel from kernel.org. You can find good links in the user comments below for other resources. Get the latest Kernel, currently linux-vserver latest stable release is for the 2.6.12.4 kernel.. which is what we get: # cd /usr/src# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.12.4.tar.gz
# tar -zxvf linux-2.6.12.4.tar.gz # gunzip patch-2.6.12.4-vs2.0.diff.gz # mv patch-2.6.12.4-vs2.0.diff /usr/src/linux-2.6.12.4 # Patch the kernel sources: # cd /usr/src/linux-2.6.12.4 # cat patch-2.6.12.4-vs2.0.diff | patch -p1
That last command is only if you want to use an existing config... please don't attempt to use a 2.4.X config file... pretty please. ;)
For future use, you should probably include LVM (and dev-mapper support)... as this is handy for virtual servers.
Enable Proc Security Enable Hard CPU Limits
# make modules_install # cp .config /boot/config-2.6.12.4-vs2.0 # cp System.map /boot/System.map-2.6.12.4-vs2.0 # cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.12.4-vs2.0 # mkinitrd -o /boot/initrd.img-2.6.12.4-vs2.0 2.6.12.4-vs2.0
root (hd0,0) kernel /vmlinuz-2.6.12.4-vs2.0 root=/dev/hda2 ro initrd /initrd.img-2.6.12.4-vs2.0 savedefault boot
2.6.12.4-vs2.0
Setting Up The Virtual ServersCreating virtual Debian Servers on a Debian host is next to ridiculously simple. The following lays it out for you: # vserver <VSERVER_NAME> build \-n <VSERVER_NAME> \ --hostname <FQDN> \ --interface <NET_DEVICE>:<IP>/<CIDR> \ -m debootstrap -- -d <DEBIAN_DISTRO>
-n vserver1 \ --hostname vserver1.mydomain.com \ --interface eth0:192.168.1.10/24 \ -m debootstrap -- -d sarge The backslashes '\' signify a new line... however you can execute this all as one command without the use of backslashes.
# ls -lah /var/lib/vservers/vserver1 total 80K drwxr-xr-x 20 root root 4.0K Nov 10 08:17 . drwxr-xr-x 4 root root 4.0K Nov 10 08:13 .. drwxr-xr-x 2 root root 4.0K Nov 10 08:17 bin drwxr-xr-x 2 root root 4.0K Dec 15 2004 boot drwxr-xr-x 3 root root 4.0K Nov 10 08:13 dev drwxr-xr-x 37 root root 4.0K Nov 10 08:17 etc drwxrwsr-x 2 root staff 4.0K Dec 15 2004 home drwxr-xr-x 2 root root 4.0K Nov 10 08:16 initrd drwxr-xr-x 7 root root 4.0K Nov 10 08:17 lib drwxr-xr-x 2 root root 4.0K Nov 10 08:16 media drwxr-xr-x 2 root root 4.0K Dec 15 2004 mnt drwxr-xr-x 2 root root 4.0K Nov 10 08:16 opt drwxr-xr-x 2 root root 4.0K Dec 15 2004 proc drwxr-xr-x 2 root root 4.0K Nov 10 08:16 root drwxr-xr-x 2 root root 4.0K Nov 10 08:17 sbin drwxr-xr-x 2 root root 4.0K Nov 10 08:16 srv drwxr-xr-x 2 root root 4.0K May 10 2005 sys drwxrwxrwt 2 root root 4.0K Nov 10 08:17 tmp drwxr-xr-x 11 root root 4.0K Nov 10 08:16 usr drwxr-xr-x 13 root root 4.0K Nov 10 08:16 var# ls -lah /etc/vservers/vserver1 total 28K drwxr-xr-x 5 root root 4.0K Nov 10 08:13 . drwxr-xr-x 6 root root 4.0K Nov 10 08:13 .. drwxr-xr-x 4 root root 4.0K Nov 10 08:13 apps -rw-r--r-- 1 root root 112 Nov 10 08:13 fstab drwxr-xr-x 3 root root 4.0K Nov 10 08:13 interfaces -rw-r--r-- 1 root root 5 Nov 10 08:13 name lrwxrwxrwx 1 root root 22 Nov 10 08:13 run -> /var/run/vservers/vserver1 drwxr-xr-x 2 root root 4.0K Nov 10 08:13 uts lrwxrwxrwx 1 root root 37 Nov 10 08:13 vdir -> /etc/vservers/.defaults/vdirbase/vserver1
Starting kernel log daemon: klogd. Starting MTA: exim4. Starting internet superserver: inetd. Starting deferred execution scheduler: atd. Starting periodic command scheduler: cron. ...# vserver-stat CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME 0 35 73.4M 5.4K 0m05s21 0m02s33 1m13s00 root server 49152 5 11M 967 0m00s00 0m00s00 0m30s52 vserver1 # vserver vserver1 enter vserver1:/#
Notes on ConfigurationYou'll first need to run "apt-setup" and configure apt same as any other debian system. The debian bootstrap install is a very minimal base installation. You will need to install everything that you want. It should be mentioned that each virtual server has its own IP address. However, since these IPs are configured as Aliases to you actually net device (i.e. eth0) they are all listening on the same physical device. This can pose a problem when default configurations specify to "Listen" on all interfaces. Every service within the vserver must specify a Listen Address.
SSH: # apt-get install sshd# vi /etc/ssh/sshd_config
|
![]() | Please do not use the comment function to ask for help! If you need help, please use our forum: http://www.howtoforge.com/forums |
![]() | Comments will be published after administrator approval. |







Recent comments
2 days 14 hours ago
4 days 10 hours ago
5 days 13 hours ago
6 days 32 min ago
6 days 15 hours ago
1 week 1 hour ago
1 week 6 hours ago
1 week 12 hours ago
1 week 2 days ago
1 week 2 days ago