February 9, 2022 Roberto Puzzanghera 4 comments
Linux-Vserver
: https://en.wikipedia.org/wiki/Linux-VServerLinux-Vserver is an open source software which acts as a virtual private server implementation done by adding operating system-level virtualization capabilities to the Linux kernel.
This means that all guests share the same kernel and they don't need to provide hardware support.
The purpose of this note is to show how to setup a guest based on Slackware
into a Slackware
host. What follows was tested on Slackware
15.0, 14.2, 14.1, 14.0, 13.37 and 13.1 (both 32b and 64b). I will assume that you have a Linux-Vserver box working. You can find here a quick and easy howto concerning Linux-Vserver
installation and configuration (patching the kernel + utils-vserver installation).
wget https://notes.sagredo.eu/files/linux-vserver/slack_vserver.tar.gz tar xzf slack_vserver.tar.gz cd slack_vserver ls
You have downloaded the following files:
First of all select a minimal set of packages to be installed on the virtual server. This list of less than 200 packages is based on the Minimal System reported at http://www.slackwiki.com/Minimal_System without all hardware, kernel and multimedia related packages. The install leads to a guest of about 500 MB of size. This set fits with the installation of a complete virtual web server including apache, apache-tomcat, php, mysql, postgresql, qmail and related, ftp, named.
I assume that the packages to be installed are stored in the slackware{$ARCH}-{$VERSION}_pkg folder. If not, adjust its location editing the make_slack_vserver.sh script.
You can download my minimal set of packages running the shell script download_slack_pkg.sh. It can create a folder like slackware{$ARCH}-{$VERSION}_pkg for you, where $ARCH has to be "64" if you want to download 64b packages or empty otherwise, while $VERSION is the Slackware version, so it's something like "15.0".
#!/bin/bash # # 2021.10.13 # Removed lines like # if [ ! -f ${FILE}*.t?z ]; then # because they prevented packages with same prefix to be downloaded (i.e. glibc, glibc-i18n) # # 2020.11.04 # Do not download patches if version is -current # # 2016.06.08 # Now the script parses comments in the package list (thanks to Mark Colclough) VERSION="15.0" # Slackware version ARCH="64" # you can put 64 for 64b cpu just to separate 64/32 download folders # Put here your favourite Slackware repository SRC=ftp://ftp.gwdg.de/pub/linux/slackware/slackware${ARCH}-${VERSION} #ftp://ftp.slackware.no/slackware/slackware${ARCH}-${VERSION} # put here your pkg list LIST=${PWD}/PKG_LIST_${VERSION} # the directory where you unpacked slack_vserver.tar.gz # $PWD should work, otherwise put /path/to/slack_vserver SETUP=../ #$PWD # the directory where you want to download the slackware packages PACKAGES=${SETUP}/slackware${ARCH}-${VERSION}_pkg # create the folder where the pkg will be downloaded if [ ! -d $PACKAGES ]; then mkdir -p $PACKAGES; fi # clean the $PACKAGES dir rm -r ${PACKAGES}/* # create the "patches" sub-folder if [ ! -d ${PACKAGES}/patches ]; then mkdir -p ${PACKAGES}/patches; fi # download cd $PACKAGES if [ -f $LIST ]; then while read LINE do [ "$LINE" ] || continue [ "${LINE#\#}" = "$LINE" ] || continue FILE=$(echo $LINE | sed -e "s/^.*\/\(.*\)/\1/") wget ${SRC}/slackware${ARCH}/${LINE}*.t?z done < $LIST else echo "Can't find $LIST file." exit 1 fi # download packages from the patches folder if [ ${VERSION} != "current" ]; then cd ${PACKAGES}/patches if [ -f ${LIST} ]; then while read LINE do IFS='/' read -ra PKG <<< "$LINE" [ "${PKG#\#}" = "${PKG}" ] || continue PKG_LEN=${#PKG[@]} if [ $PKG_LEN == 2 ]; then wget ${SRC}/patches/packages/${PKG[1]}*.t?z; fi done < $LIST else echo "Can't find $LIST file." exit 1 fi fi
Adjust the package PKG_LIST_15.0, enter your favorite ftp server and run from the command line
./download_slack_pkg.sh
NB: this script tries also to overwrite the packages downloaded from the /slackware folder with the updates belonging to the /patches dir.
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 adjusting and running the script make_slack_vserver.sh:
#!/bin/bash # # v. 2021.11.02 # Author: Roberto Puzzanghera # Thanks to Mark Colclough for corrections # # Installs a Slackware guest into a linux-vserver host (http://linux-vserver.org) # More info here: https://notes.sagredo.eu/other-contents-186/slackware-guest-on-linux-vserver-7.html # # adjust this to where your things live NAME=vtest HOSTNAME=$NAME.yourdomain.tld IPv4=168.192.1.1 IPv6=2001:41d0:1:c174::1 INTERFACE=eth0:$IPv4/24 INTERFACE6=eth0:$IPv6/64 CONTEXT=101 VERSION=15.0 # Slackware version ARCH=64 # you can put 64 for 64b cpu just to separate 64/32 download folders # where is the vservers dir? default is /vservers VDIR=/vservers # the directory where you unpacked slack_vserver.tar.gz # $PWD should work, otherwise put /path/to/slack_vserver SETUP=$PWD # the directory where you downloaded the slackware packages PACKAGES=$SETUP/slackware${ARCH}-${VERSION}_pkg # the path to rc script file (leave as is) RC=$SETUP/rc ###################################################################################### end configuration ############################################################################ do not touch anything below # 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 echo "Making skeleton..." vserver $NAME build -m skeleton \ --hostname $HOSTNAME \ --interface $INTERFACE \ --interface $INTERFACE6 \ --context $CONTEXT \ --flags lock,virt_mem,virt_uptime,virt_cpu,virt_load,sched_hard,hide_netif \ --initstyle sysv echo "...done" echo echo "Moving the /dev folder to a temp dir the /dev folder..." mv $VDIR/$NAME/dev $VDIR/$NAME/dev2 sleep 3 echo echo "Installing packages..." sleep 3 cd $PACKAGES installpkg --root $VDIR/$NAME *.t?z; # install patches if dir not empty if [ "$(ls -A patches)" ]; then ROOT=$VDIR/$NAME upgradepkg patches/*.t?z; fi echo echo echo "Installing the rc script to /etc/rc.d/init.d/rc ..." cp $RC $VDIR/$NAME/etc/rc.d/init.d/ chown root:root $VDIR/$NAME/etc/rc.d/init.d/rc chmod +x $VDIR/$NAME/etc/rc.d/init.d/rc echo echo "Removing x flag to rc.sshd, removing not needed rc scripts..." chmod -x $VDIR/$NAME/etc/rc.d/rc.sshd rm $VDIR/$NAME/etc/rc.d/rc.cpufreq $VDIR/$NAME/etc/rc.d/rc.modules* \ $VDIR/$NAME/etc/rc.d/rc.setterm \ $VDIR/$NAME/etc/rc.d/rc.inet1* $VDIR/$NAME/etc/rc.d/rc.loop \ $VDIR/$NAME/etc/rc.d/rc.K $VDIR/$NAME/etc/rc.d/rc.0 \ $VDIR/$NAME/etc/rc.d/rc.S $VDIR/$NAME/etc/rc.d/rc.4 \ $VDIR/$NAME/etc/rc.d/rc.inetd echo echo "Adjusting HOSTNAME, hosts, resolv.conf, profile. Check them 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 echo "Restoring /dev2 to /dev" rm -r $VDIR/$NAME/dev mv $VDIR/$NAME/dev2 $VDIR/$NAME/dev echo echo "Updating ca-certificates" chroot $VDIR/$NAME usr/sbin/update-ca-certificates --fresh 1> /dev/null 2> /dev/null echo echo -n "Do you want that I apply the patch for you y/n? [y] " read VAR_PATCH if [ "$VAR_PATCH" = 'y' ] || [ "$VAR_PATCH" = 'Y' ] || [ "$VAR_PATCH" = '' ]; then if [ ! -f "${SETUP}/linux-vserver_slackware-${VERSION}.patch" ]; then echo echo "Can't find any PATCH here: ${SETUP}/linux-vserver_slackware-${VERSION}.patch" echo "Exiting" echo exit 1 fi cd ${VDIR}/${NAME}/etc/rc.d patch -p1 < ${SETUP}/linux-vserver_slackware-${VERSION}.patch echo "patch applyed." echo echo "You can start and enter the virtual server typing: " echo echo "vserver $NAME start" echo "vserver $NAME enter" else echo echo "DON'T FORGET to patch /etc/rc.d as follows: " echo echo "cd ${VDIR}/${NAME}/etc/rc.d" echo "patch -p1 < ${SETUP}/linux-vserver_slackware-${VERSION}.patch" fi echo echo "More info at https://notes.sagredo.eu/other-contents-186/slackware-guest-on-linux-vserver-7.html" echo
Note that /etc/resolv.conf /etc/localtime /etc/profile are copied form the host.
Edit the script inserting at least the NAME, the IP and the CONTEXT. The packages' location should be ok if you downloaded them using my script.
./make_slack_vserver.sh
The script itsself can install the patch for you. Anyway this is how to apply the patch by yourself:
cd /vservers/vserver_name/etc/rc.d patch -p1 < /path/to/slack_vserver/slackware-15.0.patch
Inside the tarball you can find the old patch for Slackware 13.1 and 13.37, 14.0, 14.1, 14.2 if you like.
Put this inside your rc.local
:
/usr/local/etc/init.d/vprocunhide start
vserver <vserver_name> start vserver <vserver_name> enter
RBL and Bordermailer
March 20, 2023 09:31
RBL and Bordermailer
March 20, 2023 09:13
RBL and Bordermailer
March 18, 2023 15:52
Bug in dknewkey
March 18, 2023 11:35
What is qq_internal_bug_?
March 18, 2023 11:28
What is qq_internal_bug_?
March 18, 2023 11:08
What is qq_internal_bug_?
March 18, 2023 08:48
What is qq_internal_bug_?
March 18, 2023 08:08
What is qq_internal_bug_?
March 18, 2023 07:43
What is qq_internal_bug_?
March 18, 2023 04:37
Tags
apache clamav dkim dovecot ezmlm fail2ban hacks lamp letsencrypt linux linux-vserver lxc mariadb mediawiki mozilla mysql openboard owncloud patches php proftpd qmail qmail to postfix qmail-spp qmailadmin rbl roundcube rsync sieve simscan slackware solr spamassassin spf ssh ssl surbl tcprules tex ucspi-tcp vpopmail vqadmin
Comments
slackware on other distro
Maikelonline December 27, 2011 17:47
Hey,
Thanks for this great article. Does anybody got expierence of having a slackware vserver on a other distro like Debian. My host is Debian, but I want some vserver running Slackware.
Reply | Permalink
I've never tried but
roberto puzzanghera Maikelonline December 27, 2011 18:28
Hi, I've never tried but I suppose that you have to install the slackware's pkgtools on your Debian and the above script should work as is..
Please post the details if you manage to do it!
cheers :)
Reply | Permalink
no self-patch
Anonymous November 1, 2011 04:40
Hey, when i tried to install the package, the patch was not installed and after me trying to install the patch myself it hangs up. Any idea on what i might be doing wrong?
Reply | Permalink
Can you provide more details
roberto puzzanghera Anonymous November 1, 2011 10:52
Can you provide more details about the error you get, please? Everything was tested for Slackware 13.37 with the packages listed in the file PKG_LIST. I'm quite sure that it works, also yesterday I installed a slackware guest following my own directives..
cheers :)
Reply | Permalink