http://www.linux-vserver.org/index.php?title=Installation_on_Slackware&feed=atom&action=historyInstallation on Slackware - Revision history2024-03-28T09:51:36ZRevision history for this page on the wikiMediaWiki 1.20.2http://www.linux-vserver.org/index.php?title=Installation_on_Slackware&diff=4864&oldid=prevGlenn: +cat2011-10-21T19:12:34Z<p>+cat</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 19:12, 21 October 2011</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 191:</td>
<td colspan="2" class="diff-lineno">Line 191:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Contact ===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Contact ===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Any questions/comments: mailto:rhatto@riseup.net</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Any questions/comments: mailto:rhatto@riseup.net</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">[[Category:Installation]]</ins></div></td></tr>
</table>Glennhttp://www.linux-vserver.org/index.php?title=Installation_on_Slackware&diff=3625&oldid=prevJze: migrated from old wiki2009-03-27T09:17:50Z<p>migrated from old wiki</p>
<p><b>New page</b></p><div>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 a few commands. There is also a [http://slack.midiatatica.org/node/6 portuguese] version of this howto.<br />
<br />
Note that this howto is a from scratch way to do the job, there's a tool called [http://slack.midiatatica.org/node/15 simplepkg] that uses templates do create vservers and have some scripts to keep all the jails updated.<br />
<br />
== Setting up Vserver ==<br />
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.<br />
<br />
== Selecting packages ==<br />
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.<br />
<br />
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.<br />
<br />
Create a default skeleton for your vserver's config (skel.conf) and put it the the same dir of the scripts. You'll also need a tgz file with a small /dev folder containing the following devices/subfolders:<br />
crw-r--r-- 1 root root 1, 7 2004-09-13 00:00 full<br />
-rw-r--r-- 1 root root 0 2004-09-13 00:00 hdv1<br />
srw-rw-rw- 1 root root 0 2005-07-23 09:35 log<br />
crw-r--r-- 1 root root 1, 3 2004-09-13 00:00 null<br />
crw-r--r-- 1 root root 5, 2 2004-09-13 00:00 ptmx<br />
drwxr-xr-x 2 root root 0 2005-07-22 18:28 pts<br />
crw-r--r-- 1 root root 1, 8 2004-09-13 00:00 random<br />
crw-r--r-- 1 root root 5, 0 2004-09-26 15:15 tty<br />
crw-r--r-- 1 root root 1, 9 2004-09-13 00:00 urandom<br />
crw-r--r-- 1 root root 1, 5 2004-09-13 00:00 zero<br />
<br />
== Mkjail script ==<br />
Create the following /usr/local/bin/mkjail script:<br />
<pre><br />
#!/bin/bash<br />
# <br />
# mkjail v0.2: chroot jail maker (slack 10.1.0) <br />
# feedback: rhatto at riseup.net | GPL <br />
# <br />
<br />
# adjust this to where your things live<br />
PACKAGES="/storage/vserver/slack/"<br />
DEVICES="/storage/vserver/devices.tar.gz"<br />
SCRIPTS="/storage/vserver/etc/"<br />
GPGKEY="/storage/vserver/slack/GPG-KEY" <br />
SKEL="/storage/vserver/skel.conf"<br />
<br />
if (($# != 1)); then <br />
echo "usage: $0 <server-name>" <br />
exit 1 <br />
fi <br />
<br />
server=$1 <br />
mkdir /vservers/$server <br />
<br />
echo "instaling packages..." <br />
cd $PACKAGES<br />
for dir in a ap n extra contrib; do<br />
cd $dir; installpkg -root /vservers/$server *tgz; cd .. <br />
done <br />
<br />
echo "creating /etc/ and copying init scripts"<br />
rsync -Cav $SCRIPTS/ /vservers/$server/etc/ <br />
cp /etc/resolv.conf /vservers/$server/etc/<br />
cp /etc/localtime /vservers/$server/etc/<br />
echo /dev/hdv1 / ext2 defaults 1 1 > /vservers/$server/etc/fstab <br />
echo /dev/hdv1 / ext2 rw 0 0 > /vservers/$server/etc/mtab <br />
<br />
echo "creating devices and dependencies"<br />
cd /vservers/$server/ <br />
tar zxvf $DEVICES<br />
chroot /vservers/$server/ sbin/ldconfig <br />
<br />
echo "creating /etc/vservers/$server.conf" <br />
cp $SKEL /etc/vservers/$server.conf <br />
<br />
echo "importing slack gpg pubkey" <br />
mkdir /vservers/$server/root/.gnupg <br />
gpg --homedir /vservers/$server/root/.gnupg --import $GPGKEY<br />
<br />
# todo: add rebootmgr<br />
echo "done; now edit /etc/vservers/$server.conf"<br />
echo "then, set iptables rules and start $server vserver"<br />
echo "dont forget to change root's password" <br />
</pre><br />
<br />
The trick is that you can ask installpkg to install a tgz in a rootdir other than /.<br />
<br />
== Creating vservers ==<br />
Now you simple need to do a<br />
mkjail your-server<br />
and then edit /etc/vservers/your-server.conf, assigning an ip to it, choosing the capabilities, etc, and<br />
vserver your-server start<br />
Now you have a slackware vserver.<br />
<br />
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.<br />
<br />
== Upgrading vservers ==<br />
To upgrade your vservers, simple use something like this fabulous script:<br />
<pre><br />
#!/bin/sh<br />
#<br />
# vserver-upgrade v0.2: fabulous script for slack vserver upgrade<br />
# feedback: rhatto at riseup.net | GPL<br />
#<br />
# Uses some functions from pkgtools, which license is:<br />
#<br />
# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA <br />
# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA<br />
# All rights reserved.<br />
#<br />
# Redistribution and use of this script, with or without modification, is<br />
# permitted provided that the following conditions are met:<br />
#<br />
# 1. Redistributions of this script must retain the above copyright<br />
# notice, this list of conditions and the following disclaimer.<br />
#<br />
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED<br />
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF<br />
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO<br />
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,<br />
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;<br />
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,<br />
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<br />
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br />
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br />
#<br />
<br />
PACKAGE_DIR=/storage/packages/patches/<br />
<br />
# pkgtool stuff<br />
package_name() {<br />
STRING=`basename $1 .tgz`<br />
# Check for old style package name with one segment:<br />
if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then<br />
echo $STRING<br />
else # has more than one dash delimited segment<br />
# Count number of segments:<br />
INDEX=1<br />
while [ ! "`echo $STRING | cut -f $INDEX -d -`" = "" ]; do<br />
INDEX=`expr $INDEX + 1`<br />
done<br />
INDEX=`expr $INDEX - 1` # don't include the null value<br />
# If we don't have four segments, return the old-style (or out of spec) package name:<br />
if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then<br />
echo $STRING<br />
else # we have four or more segments, so we'll consider this a new-style name:<br />
NAME=`expr $INDEX - 3`<br />
NAME="`echo $STRING | cut -f 1-$NAME -d -`"<br />
echo $NAME<br />
fi<br />
fi<br />
}<br />
<br />
# vserver stuff<br />
cd $PACKAGE_DIR<br />
for file in `ls *tgz`; do<br />
pack=`package_name $file`<br />
for installed in `ls /var/log/packages/$pack* 2> /dev/null`; do<br />
if [[ "$pack" == "`package_name $installed.tgz`" ]]; then<br />
if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then<br />
upgradepkg $file<br />
fi<br />
fi<br />
done<br />
for vserver in `ls /vservers`; do<br />
for installed in `ls /vservers/$vserver/var/log/packages/$pack* 2> /dev/null`; do<br />
if [[ $pack == `package_name $installed.tgz` ]]; then<br />
if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then<br />
ROOT=/vservers/$vserver upgradepkg $file<br />
fi<br />
fi<br />
done<br />
done<br />
done<br />
</pre><br />
<br />
== Hints ==<br />
===Config format===<br />
If you're using the new configuration method for your vservers and want to use the sysv init style, you should create the following /etc/rc.d/rc script inside your vserver:<br />
<pre>#!/bin/bash<br />
<br />
if [ "$1" == "3" ]; then<br />
/etc/rc.d/rc.M<br />
elif [ "$1" == "6" ]; then<br />
/etc/rc.d/rc.6<br />
else<br />
echo "Invalid level."<br />
exit 1<br />
fi</pre><br />
<br />
=== Passive FTP ===<br />
Don't forget to put a<br />
export FTP_PASSIVE=1<br />
on your default /etc/profile.<br />
<br />
=== Contact ===<br />
Any questions/comments: mailto:rhatto@riseup.net</div>Jze