Running Vservers unders Debian/Ubuntu
Installation
- Install a vserver enables kernel
[~] # echo "deb http://ubuntu.uni-klu.ac.at/ubuntu.uniklu/ breezy uniklu-vserver" >> /etc/apt/sources.list [~] # apt-get update [~] # apt-get install linux-image-X.X.X // choose actual kernel image [~] # sync; sync; shutdown -r now
- Install all needed userland binaries
[~] # apt-get install util-vserver vserver-debiantools
Configuration
- change symlink to point to your $VROOTDIR
[~] # mkdir /home/vservers [~] # ln -snf /home/vservers /etc/vservers/.defaults/vdirbase
configure /etc/vserver/newvserver-vars as your need
#/etc/vserver/newvserver-vars # Architecture: overide on non-Debian host such as Redhat otherwise dpkg # will detect whether we are i386/powerpc/sparc/etc #ARCH="" # Which debian distribution (Warning. unstable and testing distributions # change frequently so you can not expect it to work out of the box). DIST="breezy" # Local or nearest location of a debian mirror (must include the /debian) MIRROR="http://ubuntu.uni-klu.ac.at/ubuntu" # Default network interface for vservers: INTERFACE="eth0" # Package caching #PKGCACHE=1
read details the /etc/vserver directory Configuration (flower page)
Creating Vservers
- create new vserver
[~] # newvserver -v --hostname ns0 --domain "uni-klu.ac.at" --ip IPADDRESS
- start new vserver
[~] # vserver ns0 start * Starting system log daemon... ...done. * Starting OpenBSD Secure Shell server... ...done.
- enter the new vserver
[~] # vserver ns0 enter ns0: [~] # apt-get update && apt-get dist-upgrade && apt-get install PACKAGES ns0: [~] # // what ever you want ns0: [~] # exit [~] #
- remove all hardware specific packages (only if isnt done by newvserver)
[~] # vserver ns0 enter ns0: [~] # REMOVE_PACKAGES="sparc-utils dhcp-client lilo makedev pcmcia-cs ppp pppconfig pppoe pppoeconf setserial syslinux fdutils libpcap0 iptables pciutils" ns0: [~] # dpkg -P `echo $REMOVE_PACKAGES`
- remove all hardware specific init scripts (only if isnt done by newvserver)
[~] # vserver ns0 enter ns0: [~] # for link in klogd hwclock.sh setserial urandom networking umountfs halt reboot mountvirtfs mountall.sh mountnfs.sh ifupdown; do > update-rc.d -f $link remove > update-rc.d -f $link stop 90 3 . > done
- stop the vserver
[~] # vserver ns0 stop * Stopping OpenBSD Secure Shell server... [ ok ] * Stopping system log daemon... [ ok ] * Sending all processes the TERM signal... [ ok ] * Sending all processes the KILL signal... [ ok ] * Unmounting remote and non-toplevel virtual filesystems... [ ok ] * Shutting down LVM Volume Groups... [ ok ]
- let init start the new vserver
[~] # echo "default" > /etc/vservers/ns0/apps/init/mark
- test init script
[~] # /etc/init.d/vserver-default start Starting vservers of type 'default'.... [~] # vserver-stat CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME 0 73 219.2M 100.3M 4h28m22 19m27s15 5d23h57 root server 49156 1 1.5M 540K 0m01s32 0m02s28 21h49m30 49161 2 5.1M 2.2M 0m00s00 0m00s00 0m02s47 ns0 [~] # /etc/init.d/vservers-default stop Stopping vservers of type 'default'.... [~] # vserver-stat CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME 0 73 219.2M 100.3M 4h28m22 19m26s99 5d23h57 root server 49156 1 1.5M 540K 0m01s32 0m02s28 21h49m23
Useful vserver binaries
- vapt-get: use apt-get in given/all vservers
[~] # vserver ns0 enter ns0: [~] # htop bash: htop: command not found ns0: [~] # exit [~] # vapt-get ns0 -- install htop Reading package lists... Done Building dependency tree... Done The following NEW packages will be installed: htop 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 40.2kB of archives. After unpacking 164kB of additional disk space will be used. Get:1 http://ubuntu.uni-klu.ac.at breezy/universe htop 0.5.2-1 [40.2kB] Fetched 40.2kB in 0s (710kB/s) Preconfiguring packages ... Selecting previously deselected package htop. (Reading database ... 9417 files and directories currently installed.) Unpacking htop (from .../archives/htop_0.5.2-1_i386.deb) ... Setting up htop (0.5.2-1) ... [~] # vserver ns0 enter ns0: [~] # htop
- vps: like ps but includes vservers
[~] # vps -ef [snip] root 8102 0 MAIN 8100 0 12:40 pts/1 00:00:00 -bash root 8210 49159 ns0 5542 0 12:49 ? 00:00:00 sshd: root@pts/2 root 8212 49159 ns0 8210 0 12:49 pts/2 00:00:00 -bash root 8271 1 ALL_PROC 8102 0 12:57 pts/1 00:00:00 vps -ef root 8272 1 ALL_PROC 8271 0 12:57 pts/1 00:00:00 ps -ef [snip]
- vserver-stat: get statistics about vservers
[~] # vserver-stat CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME 0 73 219.2M 100.2M 4h28m20 19m26s26 5d23h37 root server 49156 1 1.5M 540K 0m01s31 0m02s24 21h29m00 49159 2 5.1M 2.2M 0m00s15 0m00s40 19h22m55 ns0
- vserver-copy: copy an existing vserver
# FROM THE MANPAGE OF vserver-copy # Copy a template vserver (same IP addresses etc) [~] # /usr/sbin/vserver-copy template web01 # Copy webserver with change in configuration [~] # /usr/sbin/vserver-copy -i 192.168.5.62 -d example.com template web62 # Move a running vserver to another roothost [~] # /usr/sbin/vserver-copy -s web62 roothost02: