We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

This is a quick-and-dirty Slackware Vserver Howto as I haven't seen anything about vserver on slack. The advantage of this approach is that you can easily setup new vsevers and keep all of them up to date with the slackware packaging system, with just few commands.

Setting up Vserver

First I assume you have successfully compiled and booted a kernel with vserver patch, installed the util-vserver package and created a /vservers with the chroot-barrier.

Selecting packages

Then, put all your preffered slack packages on some dir, eg /slackware, respecting the default disk sets hierarchy. You can leave just the most essential packs, like some of the a, ap, n and l sets.

Now copy and edit the /etc/profile and all the rc.d's scripts you want to some place, for example /scripts. Do a chmod +x to any script you want to start at the vserver initialization, and a -x to what you dont want.

Create a default skeleton for your vserver's config (skel.conf) and put it the the same dir of the scripts.

Mkjail script

Create the following /usr/local/bin/mkjail script:

#!/bin/bash
#
# mkjail: create vservers
# feedback: rhatto at riseup.net
#

# adjust this to where your packages live
PACKAGES=/slackware

# this is where you put the rc's scripts
SCRIPTS=/scripts

# which disk sets you want to install
SERIES="a ap l n"

if (($# != 1)); then
  echo "usage: $0 <server-name>"
  exit 1
fi

server=$1
mkdir /vservers/$server

echo "installing the packages"
cd $PACKAGES
for dir $SERIES; do
  cd $dir; installpkg -root /vservers/$server *tgz; cd ..
done

echo "copying initialization scripts"
cp $SCRIPTS/rc.* /vservers/$server/etc/rc.d/
cp /etc/resolv.conf /vservers/$server/etc/

echo "creating /etc/fstab /etc/mtab /etc/localtime /etc/profile"
echo /dev/hdv1 / ext2 defaults 1 1 > /vservers/$server/etc/fstab
echo /dev/hdv1 / ext2 rw 0 0 > /vservers/$server/etc/mtab
cp /etc/localtime /vservers/$server/etc/
cp $SCRIPTS/profile /vservers/$server/etc

echo "creating dependency cache"
cd /vservers/$server/ 
tar xvf /storage/vserver/vserver-dev.tar
ln -s lib/ld-2.3.2.so lib/ld-linux.so.2
chroot /vservers/$server/ sbin/ldconfig

echo "creating config file"
cp $SCRIPTS/skel.conf /etc/vservers/$server.conf

echo "done; now edit /etc/vservers/$server.conf"
echo "then, route your server thru iptables and start it"
echo "dont forget to change your vserver's root passwd"

The trick is that you can ask installpkg to install a tgz in a rootdir other than /.

Creating vservers

Now you simple need to do a

mkjail your-server

and then edit /etc/vservers/your-server.conf, assigning an ip to it, choosing the capabilities, etc, and

vserver your-server start

Now you have a slackware vserver.

For the first time you start or stop your vserver maybe you get some errors from the scripts like rc.6 trying to umount devices or something like. Just remove these commands from the scripts and everything works fine.

Upgrading vservers

To upgrade your vservers, simple use something like this fabulous script:

#!/bin/bash
#
# vserver-upgrade
#

# where your patches live
PATCHES=/slackware/patches/packages/

cd $PATCHES
for file in $(ls *tgz); do
  pack=$(echo $file | cut -d - -f 1)
  # this upgrades your main system
  if [ -f /var/log/packages/$pack* ]; then 
    upgradepkg $pack*tgz
  fi
  # this upgrades packages on every vserver running slackware
  for vserver in $(ls /vservers); do
    if [ -f /vservers/$vserver/var/log/packages/$pack* ]; then
      ROOT=/vservers/$vserver upgradepkg $pack*tgz
    fi
  done
done

Tips

Don't forget to put a

export FTP_PASSIVE=1

on your default /etc/profile.