Building VServers on Slackware 12.0
This is still very much a work in progress, so things might change. If you have suggestions or comments, they are more than welcome ;).
This will be how to on setting up minimal Slackware 12.0 VServer guests on a Slackware 12.0 host. I’ve been trying to find a decent guide on how to do this, but almost all documentaton was either insufficient or heavily outdated. Even the Linux-VServer.org documentation is rather lacking in my opinion…
Before we start, you will need a kernel which has been patched to work with Linux-VServer and the util-vserver software. I’ve created a couple of simple scripts to aid in setting up minimal Slackware guests: http://www.cilinder.be/slackware/12.0/svs-0.1.tar.gz.
Next, you will need the util-vserver tools which are the Linux-VServer userland tools. You can download my Slackware 12 package here: util-vserver-0.30.214-i486-1tfx.tgz (md5). Install via the normal Slackware method (”installpkg util-vserver-0.30.214-i486-1tfx.tgz”).
We start by creating a template. I’ve based my list of installed packages on the Linux from Slack and Minimal System pages on Slackwiki.org. You can find the list of packages that will be installed in the template VServer in the svs scripts above (look for the “vserver.list” file). Download the above scripts and extract them to a local directory:
$ wget http://www.cilinder.be/slackware/svs-0.1.tar.gz
$ tar zxpvf svs-0.1.tar.gz
The files get.sh, inst.sh and vserver.list should now be available in your current working directory. Get.sh will fetch the necessary packages from a Slackware mirror. Inst.sh will install the downloaded packages to /vservers/template. The file vserver.list contains the necessary packages for a minimal Slackware VServer. It’s probably a good idea to change the Slackware mirror in the get.sh to something that’s closer to your location.
We’ll begin by fetching the necessary Slackware 12.0 packages with get.sh:
$ ./get.sh
When this is done, there will be a new directory “slackware” in your current working directory with a bunch of packages. For the next part, you’ll have to become root. When you are, run inst.sh:
# ./inst.sh
This will install the above downloaded packages in /vservers/template which will become our template directory for future Slackware VServers. Next, descent in the directory /vservers/template/dev and remove the devices listed there:
# cd /vservers/template/dev/
# rm -Rf *
We will also have to create a System V initialization script in /vservers/template/etc/init.d/:
# vi /vservers/template/etc/init.d/rc
Add the following in the above file:
if [ $1 -eq 3 ]; then
echo "entering runlevel 3: multi";
/etc/rc.d/rc.M
fi
if [ $1 -eq 6 ]; then
echo "entering runlevel 6: reboot";
/etc/rc.d/rc.6
fi
if [ $1 -eq 0 ]; then
echo "entering runlevel 0: shutdown";
/etc/rc.d/rc.0
fi
if [ $1 -eq 4 ]; then
echo "entering runlevel 4";
fi
if [ $1 -eq 5 ]; then
echo "entering runlevel 5";
fi
if [ $1 -eq 1 ]; then
echo "entering runlevel 1:single";
/etc/rc.d/rc.K
fi
if [ $1 -eq 2 ]; then
echo "entering runlevel 2:multi";
/etc/rc.d/rc.M
fi
Don’t forget to give that file execution permissions otherwise it won’t run when we start our VServer:
# chmod u+x /vservers/template/etc/init.d/rc
After this is done, we will need to apply a patch (found here: slack12.diff) which will disable the Slackware hardware related startup scripts:
# cd /vservers/template
# wget http://www.cilinder.be/slackware/12.0/slack12.diff
# patch -p1 < slack12.diff
We will also have to disable “/etc/rc.d/rc.inet1″ from being run on startup:
# chmod -x /vservers/template/etc/rc.d/rc.inet1
The next command will create a new skeleton vserver under /vservers/vserver1 with the necessary devices:
# NAME=vserver1
# INTERFACE=eth0:10.0.0.1/24
# CONTEXT=1000
# vserver ${NAME} build -m skeleton --context ${CONTEXT} --interface
${INTERFACE} --flags lock,virt_mem,virt_uptime,virt_cpu,virt_load,sched_hard,hide_netif
--initstyle sysv
In the above example, change the NAME, INTERFACE and CONTEXT fiels to whatever it needs to be on your machine. After that, you will have a new directory /vserver/vserver1. Now we will copy our template directory that newly created directory:
# cd /vservers/
# cp -a template/. vserver1/.
At this point, our VServer should already be able to boot. We can test this with:
# /usr/sbin/vserver vserver1 start
You’ll probably see a lot of error messages, this is due to the Slackware startup scripts that are executed in the VServer related to configuring and starting hardware devices. I’m still working on a diff to patch the template directory to remove those. When the VServer has been booted, you can access it with:
# /usr/sbin/vserver vserver1 enter
At this point you can start “netconfig” and start configuring your newly created Slackware 12.0 VServer. It’s probably a good idea to have a ‘localhost’ in your vserver. This can be achieved by creating a new folder in /etc/vservers/${NAME}/interfaces/. Name the folder 1, if the previous one that exists there is 0. Then create files named ‘ip’, ‘dev’ and ‘prefix’ and write 127.0.0.1 to ip, lo to dev and 32 to prefix:
# mkdir /etc/vservers/${NAME}/interfaces/1/
# echo 127.0.0.1 > /etc/vservers/${NAME}/interfaces/1/ip
# echo 32 > /etc/vservers/${NAME}/interfaces/1/prefix
# echo lo > /etc/vservers/${NAME}/interfaces/1/dev
Just a minor problem:
wget http://www.cilinder.be/slackware/slack12.diff
ERROR 404: Not Found
He yeah. That might give problems :) Can you try again? Also, can you let me know whether everything is working for you?