Difference between revisions of "Installation on Slackware 13"

From Linux-VServer

Jump to: navigation, search
(Notes)
(Contact)
Line 196: Line 196:
 
* delete all mounts and other hardware related command line in ''rc.0 rc.6 rc.K rc.M rc.inet2''
 
* delete all mounts and other hardware related command line in ''rc.0 rc.6 rc.K rc.M rc.inet2''
  
==== Contact ====
+
== Contact ==
 
Any comment/suggestion/question to ''roberto.puzzanghera at sagredo dot eu'', [http://notes.sagredo.eu]
 
Any comment/suggestion/question to ''roberto.puzzanghera at sagredo dot eu'', [http://notes.sagredo.eu]

Revision as of 21:49, 28 October 2010

What follows was tested on a Slackware 13.1 guest. I assume you have a Linux-Vserver host working.

Contents

Download the patch and the installer script

cd /usr/local/src
wget http://notes.sagredo.eu/sites/notes.sagredo.eu/files/linux-vserver/slack_vserver.tar.gz
tar xzf slack_vserver.tar.gz
chown -R root.root slack_vserver

ls
  • slackware-13.1.patch is the patch which modify rc.0 rc.6 rc.M rc.K and rc.inet2. It must be applyed after the creation of the guest. In the patch I switched off all the executable that are related to the hardware, including the rc.inet1, and rc.6. Inside rc./d/init.d/ you can find the rc script that starts the vserver. Comments would be welcome about this :-).
  • make_slack_vserver.sh is the shell script that you have to adjust. It installs the guest.
  • rc is the startup script for the virtual server. It will be automatically copied in /etc/rc.d/init.d/rc
  • PKG_LIST is my Slackware package list
  • download_slack.sh is a script that you can use to download all the PKG_LIST

Download the slack packages

First of all select a minimal set of packages to be installed on the virtual server. This list of 108 packages is based on the Minimal System reported at http://slackwiki.org/Minimal_System without all hardware, kernel and multimedia related packages. The install leads to a guest of about 448M of size.

Create a folder where to store the Slackware packages to install in the new server.

mkdir slackware 
cd slackware

If you decide to download the packages via ftp, create here a file PKG_LIST with the packages' list inside.

To download the packages you can use a script like this:

#!/bin/bash
 
LIST="PKG_LIST"
SRC="ftp://ftp.slackware.no/slackware/slackware-13.1/slackware/"
#"ftp://ftp.slackware.no/slackware/slackware64-13.1/slackware64/"
 
if [ -f $LIST ]; then
        while read line  
            do  
            wget "$SRC$line*.t?z"
        done < $LIST
fi

Adjust the packages' list, enter your favorite ftp server and run from the command line.

Make the guest

Now let's create the guest and install the packages. As you know you must choose at least a "name", a "context" and an ip. In addition you have to modify most of the rc.* startup scripts removing all the hardware related daemons, and finally replace the /dev dir.

This is done running the script make_slack_vserver.sh that you downloaded before. Edit the file make_slack_vserver.sh and adjust it to your needs.

#!/bin/bash
#
# More info here: http://notes.sagredo.eu/node/7
 
if [ $# != 1 ]; then
  echo "usage: $0 <server-name>"
  exit 1
fi
 
# adjust this to where your things live
NAME=$1
HOSTNAME=$NAME.myserver.net
IP=10.0.0.147
INTERFACE=eth0:$IP/24
CONTEXT=1010
 
# where is the vservers dir? default is /vservers
VDIR="/usr/local/vservers"
 
# the directory where you unpacked slack_vserver.tar.gz
SETUP="/path/to/slack_vserver"
 
# the directory where you downloaded the slackware packages
PACKAGES="$SETUP/slackware"
 
# the patch to rc script file (leave as is)
RC="$SETUP/rc"
 
################### end configuration
 
# sanity check
 
if [ ! -d "$VDIR" ]; then
        echo ""
        echo "Can't find VDIR dir: $VDIR"
        echo "Exiting"
        echo ""
        exit 1
fi
if [ ! -d "$SETUP" ]; then
        echo ""
        echo "Can't find SETUP dir: $SETUP"
        echo "Exiting"
        echo ""
        exit 1
fi
if [ ! -d "$PACKAGES" ]; then
        echo ""
        echo "Can't find PACKAGES dir: $PACKAGES"
        echo "Exiting"
        echo ""
        exit 1
fi
if [ ! -f "$RC" ]; then
        echo ""
        echo "Can't find RC path: $RC"
        echo "Exiting"
        echo ""
        exit 1
fi
 
# if everything is ok start the install
 
echo ""
read -p "press any key to make skeleton..."
vserver ${NAME} build -m skeleton \
        --hostname ${HOSTNAME} \
        --interface ${INTERFACE} \
        --flags lock,virt_mem,virt_uptime,virt_cpu,virt_load,sched_hard,hide_netif \
        --initstyle sysv
echo "...done"
echo ""
 
read -p "press any key to move to a temp dir the /dev folder..."
mv $VDIR/$NAME/dev $VDIR/$NAME/dev2
 
echo ""
read -p "press any key to install packages..."
cd $PACKAGES
installpkg -root $VDIR/$NAME *.t?z;
echo "...done"
echo ""
 
echo ""
read -p "press any key to copy rc script to /etc/rc.d/init.d..."
echo ""
echo "copying rc to /etc/rc.d/init.d/rc"
echo ""
cp -p $RC $VDIR/$NAME/etc/rc.d/init.d/
echo "done"
 
echo ""
echo "removing x flag to rc.inet1 and rc.sshd"
chmod -x $VDIR/$NAME/etc/rc.d/rc.inet1 $VDIR/$NAME/etc/rc.d/rc.sshd
echo "done"
echo ""
 
echo "trying to adjust HOSTNAME, hosts, resolv.conf, profile. Check later..."
cp /etc/resolv.conf $VDIR/$NAME/etc/
cp /etc/localtime $VDIR/$NAME/etc/
rm $VDIR/$NAME/etc/profile
cp /etc/profile $VDIR/$NAME/etc/
echo $HOSTNAME >  $VDIR/$NAME/etc/HOSTNAME
echo "127.0.0.1 localhost" > $VDIR/$NAME/etc/hosts
echo "$IP $HOSTNAME $NAME" >> $VDIR/$NAME/etc/hosts
touch $VDIR/$NAME/etc/mtab
touch $VDIR/$NAME/etc/fstab
echo "done"
 
echo ""
read -p "press any key to restore /dev2 to /dev"
rm -r $VDIR/$NAME/dev
mv $VDIR/$NAME/dev2 $VDIR/$NAME/dev
 
echo ""
echo "done; DON'T FORGET to patch /etc/rc.d: "
echo "cd $VDIR/$NAME/etc/rc.d"
echo "patch -p1 < $SETUP/slackware-13.1.patch"
echo ""
echo "More info on http://notes.sagredo.eu/node/7"
echo ""

Note that /etc/resolv.conf /etc/localtime /etc/profile are copied form the host. Run it to install the server and all the packages you downloaded.

Apply the patch and start the guest

Once you have installed the server apply the patch:

cd /vservers/vserver_name/etc/rc.d
patch -p1 < /path/to/slack_vserver/slackware-13.1.patch

vserver <vserver_name> start
vserver <vserver_name> enter

Notes

My patch has been tested with Slackware 13.1, but I suppose that this solution should work also in future version with some small adjustment. In any case, if the patch doesn't work with your version of Slackware try to replace rc.0 rc.6 rc.K rc.M rc.inet2 with these (download here). In addition remember to

  • leave /etc/rc.d/init.d/rc script as is. These is a very essential script which is started first and runs rc.M on startup or rc.6 on shutdown
  • chmod -x rc.inet1 the network is brought up configuring the guest by /etc/vservers
  • chmod -x all hardware related services like rc.acpid rc.alsa rc.pcmcia rc.wireless rc.gpm rc.bluetooth rc.hald
  • delete all mounts and other hardware related command line in rc.0 rc.6 rc.K rc.M rc.inet2

Contact

Any comment/suggestion/question to roberto.puzzanghera at sagredo dot eu, [1]

Personal tools