Difference between revisions of "Installation on Slackware 14"
From Linux-VServer
(→Download the packages) |
(→Contact) |
||
(19 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | The purpose of this note is to setup a guest based on Slackware. What follows was tested on Slackware 14. | + | The purpose of this note is to setup a guest based on Slackware. What follows was tested on Slackware 14.2 to 13.1 (both 32b and 64b). I will assume that you have a Linux-Vserver box working. |
== Download == | == Download == | ||
<pre> | <pre> | ||
− | wget | + | wget https://notes.sagredo.eu/sites/notes.sagredo.eu/files/linux-vserver/slack_vserver.tar.gz |
tar xzf slack_vserver.tar.gz | tar xzf slack_vserver.tar.gz | ||
cd slack_vserver | cd slack_vserver | ||
Line 15: | Line 15: | ||
* <em>make_slack_vserver.sh</em> is the shell script that you have to adjust. It installs the guest. | * <em>make_slack_vserver.sh</em> is the shell script that you have to adjust. It installs the guest. | ||
* <em>rc</em> is the startup script for the virtual server. It will be automatically copied in /etc/rc.d* /init.d/rc | * <em>rc</em> is the startup script for the virtual server. It will be automatically copied in /etc/rc.d* /init.d/rc | ||
− | * <em>linux-vserver_slackware-14. | + | * <em>linux-vserver_slackware-14.2.patch</em> is the patch which modify rc.0, rc.6 rc.M, rc.S, rc.inet2 and rc.syslog. It must be applyed after the creation of the vserver process. In the patch I switched off all the mounts and executable that are related to the hardware. |
== Download the packages == | == Download the packages == | ||
− | First of all select a minimal set of packages to be installed on the virtual server. This list of | + | First of all select a minimal set of packages to be installed on the virtual server. This list of 123 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 460M 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''. | 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 "14. | + | 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 "14.2". |
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
− | # v. | + | # v. 2016.06.08 |
+ | # Now the script parses comments in the package list (thanks to Mark Colclough) | ||
− | VERSION="14. | + | VERSION="14.2" # Slackware version |
ARCH="64" # you can put 64 for 64b cpu just to separate 64/32 download folders | ARCH="64" # you can put 64 for 64b cpu just to separate 64/32 download folders | ||
Line 43: | Line 44: | ||
SETUP=$PWD | SETUP=$PWD | ||
− | # the directory where you | + | # the directory where you want to download the slackware packages |
PACKAGES="${SETUP}/slackware${ARCH}-${VERSION}_pkg" | PACKAGES="${SETUP}/slackware${ARCH}-${VERSION}_pkg" | ||
Line 61: | Line 62: | ||
if [ -f $LIST ]; then | if [ -f $LIST ]; then | ||
while read LINE | while read LINE | ||
− | do | + | do |
+ | [ "$LINE" ] || continue | ||
+ | [ "${LINE#\#}" = "$LINE" ] || continue | ||
wget "${SRC}slackware${ARCH}/${LINE}*.t?z" | wget "${SRC}slackware${ARCH}/${LINE}*.t?z" | ||
done < $LIST | done < $LIST | ||
Line 68: | Line 71: | ||
exit 1 | exit 1 | ||
fi | fi | ||
− | |||
− | |||
# download packages from the patches folder | # download packages from the patches folder | ||
Line 78: | Line 79: | ||
do | do | ||
IFS='/' read -ra PKG <<< "$LINE" | IFS='/' read -ra PKG <<< "$LINE" | ||
+ | [ "${PKG#\#}" = "${PKG}" ] || continue | ||
PKG_LEN=${#PKG[@]} | PKG_LEN=${#PKG[@]} | ||
if [ $PKG_LEN == 2 ]; then | if [ $PKG_LEN == 2 ]; then | ||
Line 87: | Line 89: | ||
exit 1 | exit 1 | ||
fi | fi | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Line 107: | Line 101: | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
− | # v. | + | # v. 2016.07.05 |
# Author: Roberto Puzzanghera | # Author: Roberto Puzzanghera | ||
+ | # Thanks to Mark Colclough for corrections | ||
# | # | ||
# This script installs a Slackware guest into a linux-vserver host (http://linux-vserver.org) | # This script installs a Slackware guest into a linux-vserver host (http://linux-vserver.org) | ||
# | # | ||
# Comments are welcome :-) | # Comments are welcome :-) | ||
− | # More info here: | + | # More info here: https://notes.sagredo.eu/other-contents-186/slackware-guest-on-linux-vserver-7.html |
# adjust this to where your things live | # adjust this to where your things live | ||
NAME=test | NAME=test | ||
− | HOSTNAME=$NAME. | + | HOSTNAME=$NAME.YOURDOMAIN.XY |
− | IP=10.0.0. | + | IP=10.0.0.182 |
INTERFACE=eth0:$IP/24 | INTERFACE=eth0:$IP/24 | ||
− | CONTEXT= | + | CONTEXT=5182 |
− | VERSION=14. | + | VERSION=14.2 # Slackware version |
− | ARCH=64 # you can put 64 for 64b cpu just to separate 64/32 download folders | + | ARCH="64" # you can put 64 for 64b cpu just to separate 64/32 download folders |
# where is the vservers dir? default is /vservers | # where is the vservers dir? default is /vservers | ||
Line 146: | Line 141: | ||
echo "Exiting" | echo "Exiting" | ||
echo | echo | ||
− | exit 1 | + | exit 1 |
fi | fi | ||
if [ ! -d "$SETUP" ]; then | if [ ! -d "$SETUP" ]; then | ||
− | echo | + | echo |
echo "Can't find SETUP dir: $SETUP" | echo "Can't find SETUP dir: $SETUP" | ||
echo "Exiting" | echo "Exiting" | ||
Line 187: | Line 182: | ||
echo | echo | ||
− | read -p "press any key to install packages..." | + | read -p "press any key to install packages..." |
cd $PACKAGES | cd $PACKAGES | ||
− | installpkg -root $VDIR/$NAME *.t?z; | + | installpkg --root $VDIR/$NAME *.t?z; |
− | upgradepkg patches/*.t?z; | + | ROOT=$VDIR/$NAME upgradepkg patches/*.t?z; |
− | echo "...done" | + | echo "...done" |
echo | echo | ||
Line 202: | Line 197: | ||
echo | echo | ||
− | echo "removing x flag to rc. | + | echo "removing x flag to rc.sshd and rc.inetd, removing not needed rc scripts" |
− | chmod -x $VDIR/$NAME/etc/rc.d/rc. | + | chmod -x $VDIR/$NAME/etc/rc.d/rc.sshd $VDIR/$NAME/etc/rc.d/rc.inetd |
+ | rm $VDIR/$NAME/etc/rc.d/rc.cpufreq $VDIR/$NAME/etc/rc.d/rc.modules* $VDIR/$NAME/etc/rc.d/rc.inet1* $VDIR/$NAME/etc/rc.d/rc.loop | ||
echo "...done" | echo "...done" | ||
echo | echo | ||
− | echo "trying to adjust HOSTNAME, hosts, resolv.conf, profile. Check later..." | + | echo "trying to adjust HOSTNAME, hosts, resolv.conf, profile. Check them later..." |
cp /etc/resolv.conf $VDIR/$NAME/etc/ | cp /etc/resolv.conf $VDIR/$NAME/etc/ | ||
cp /etc/localtime $VDIR/$NAME/etc/ | cp /etc/localtime $VDIR/$NAME/etc/ | ||
Line 215: | Line 211: | ||
echo "127.0.0.1 localhost" > $VDIR/$NAME/etc/hosts | echo "127.0.0.1 localhost" > $VDIR/$NAME/etc/hosts | ||
echo "$IP $HOSTNAME $NAME" >> $VDIR/$NAME/etc/hosts | echo "$IP $HOSTNAME $NAME" >> $VDIR/$NAME/etc/hosts | ||
− | touch $VDIR/$NAME/etc/mtab | + | touch $VDIR/$NAME/etc/mtab |
touch $VDIR/$NAME/etc/fstab | touch $VDIR/$NAME/etc/fstab | ||
echo "...done" | echo "...done" | ||
Line 246: | Line 242: | ||
echo "vserver $NAME start" | echo "vserver $NAME start" | ||
echo "vserver $NAME enter" | echo "vserver $NAME enter" | ||
− | + | ||
else | else | ||
echo | echo | ||
Line 258: | Line 254: | ||
echo "More info on http://notes.sagredo.eu/node/7" | echo "More info on http://notes.sagredo.eu/node/7" | ||
echo | echo | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Line 272: | Line 261: | ||
<pre> | <pre> | ||
cd /vservers/vserver_name/etc/rc.d | cd /vservers/vserver_name/etc/rc.d | ||
− | patch -p1 < /path/to/slack_vserver/slackware-14. | + | patch -p1 < /path/to/slack_vserver/slackware-14.2.patch |
</pre> | </pre> | ||
− | Inside the tarball you can find the old patch for Slackware | + | Inside the tarball you can find the old patch for Slackware 14.1, 14.0, 13.37 and 13.1, if you like. |
== Post installation tasks == | == Post installation tasks == | ||
Line 292: | Line 281: | ||
== Patch applayed == | == Patch applayed == | ||
<pre> | <pre> | ||
− | + | diff -ruN rc.d-original/rc.6 rc.d/rc.6 | |
− | + | --- rc.d-original/rc.6 2016-03-26 17:48:37.000000000 +0100 | |
− | + | +++ rc.d/rc.6 2016-07-09 14:08:48.470713168 +0200 | |
− | + | @@ -37,36 +37,6 @@ | |
− | + | ;; | |
− | + | ||
− | diff -ruN rc.d-original/rc. | + | |
− | --- rc.d-original/rc. | + | |
− | +++ rc.d/rc. | + | |
− | @@ -37, | + | |
− | + | ||
esac | esac | ||
-# Save the system time to the hardware clock using hwclock --systohc. | -# Save the system time to the hardware clock using hwclock --systohc. | ||
+ | -# This will also create or update the timestamps in /etc/adjtime. | ||
-if [ -x /sbin/hwclock ]; then | -if [ -x /sbin/hwclock ]; then | ||
- # Check for a broken motherboard RTC clock (where ioports for rtc are | - # Check for a broken motherboard RTC clock (where ioports for rtc are | ||
- # unknown) to prevent hwclock causing a hang: | - # unknown) to prevent hwclock causing a hang: | ||
− | - if ! grep -q | + | - if ! grep -q " : rtc" /proc/ioports ; then |
- CLOCK_OPT="--directisa" | - CLOCK_OPT="--directisa" | ||
- fi | - fi | ||
− | - if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then | + | - if [ /etc/adjtime -nt /etc/hardwareclock ]; then |
+ | - if grep -q "^LOCAL" /etc/adjtime ; then | ||
+ | - echo "Saving system time to the hardware clock (localtime)." | ||
+ | - else | ||
+ | - echo "Saving system time to the hardware clock (UTC)." | ||
+ | - fi | ||
+ | - /sbin/hwclock $CLOCK_OPT --systohc | ||
+ | - elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then | ||
- echo "Saving system time to the hardware clock (UTC)." | - echo "Saving system time to the hardware clock (UTC)." | ||
+ | - if [ ! -r /etc/adjtime ]; then | ||
+ | - echo "Creating system time correction file /etc/adjtime." | ||
+ | - fi | ||
- /sbin/hwclock $CLOCK_OPT --utc --systohc | - /sbin/hwclock $CLOCK_OPT --utc --systohc | ||
- else | - else | ||
- echo "Saving system time to the hardware clock (localtime)." | - echo "Saving system time to the hardware clock (localtime)." | ||
− | - /sbin/hwclock | + | - if [ ! -r /etc/adjtime ]; then |
+ | - echo "Creating system time correction file /etc/adjtime." | ||
+ | - fi | ||
+ | - /sbin/hwclock $CLOCK_OPT --localtime --systohc | ||
- fi | - fi | ||
-fi | -fi | ||
Line 324: | Line 321: | ||
if [ -x /etc/rc.d/rc.local_shutdown ]; then | if [ -x /etc/rc.d/rc.local_shutdown ]; then | ||
/etc/rc.d/rc.local_shutdown stop | /etc/rc.d/rc.local_shutdown stop | ||
− | @@ - | + | @@ -126,10 +96,6 @@ |
− | + | sleep $FUSER_DELAY | |
fi | fi | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
-# Unmount any NFS, SMB, or CIFS filesystems: | -# Unmount any NFS, SMB, or CIFS filesystems: | ||
− | -echo "Unmounting remote filesystems | + | -echo "Unmounting remote filesystems:" |
− | -/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs | + | -/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" |
- | - | ||
# Try to shut down pppd: | # Try to shut down pppd: | ||
PS="$(ps ax)" | PS="$(ps ax)" | ||
if echo "$PS" | /bin/grep -q -w pppd ; then | if echo "$PS" | /bin/grep -q -w pppd ; then | ||
− | @@ - | + | @@ -215,22 +181,11 @@ |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
# Before unmounting file systems write a reboot or halt record to wtmp. | # Before unmounting file systems write a reboot or halt record to wtmp. | ||
− | $ | + | $shutdown_command -w |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
-# Turn off swap: | -# Turn off swap: | ||
Line 421: | Line 341: | ||
-/bin/sync | -/bin/sync | ||
- | - | ||
− | -echo "Unmounting local file systems | + | # Stop cgmanager and cgproxy: |
− | -/bin/umount -v -a -t no,proc,sysfs | + | if [ -x /etc/rc.d/rc.cgmanager ]; then |
+ | sh /etc/rc.d/rc.cgmanager stop | ||
+ | fi | ||
+ | |||
+ | -echo "Unmounting local file systems:" | ||
+ | -/bin/umount -v -a -t no,proc,sysfs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" 2> /dev/null | ||
- | - | ||
− | -echo "Remounting root filesystem read-only | + | -echo "Remounting root filesystem read-only:" |
-/bin/mount -v -n -o remount,ro / | -/bin/mount -v -n -o remount,ro / | ||
- | - | ||
# This never hurts: | # This never hurts: | ||
/bin/sync | /bin/sync | ||
− | + | ||
− | + | @@ -288,12 +243,3 @@ | |
− | + | fi | |
− | + | fi | |
− | - | + | fi |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
- | - | ||
-# Now halt (poweroff with APM or ACPI enabled kernels) or reboot. | -# Now halt (poweroff with APM or ACPI enabled kernels) or reboot. | ||
− | -if [ "$ | + | -if [ "$shutdown_command" = "reboot" ]; then |
- echo "Rebooting." | - echo "Rebooting." | ||
- /sbin/reboot | - /sbin/reboot | ||
Line 493: | Line 368: | ||
-fi | -fi | ||
- | - | ||
− | diff -ruN rc.d-original/rc. | + | diff -ruN rc.d-original/rc.M rc.d/rc.M |
− | --- rc.d-original/rc. | + | --- rc.d-original/rc.M 2016-05-05 06:27:00.000000000 +0200 |
− | +++ rc.d/rc. | + | +++ rc.d/rc.M 2016-07-09 14:14:20.090096570 +0200 |
− | @@ - | + | @@ -20,10 +20,6 @@ |
− | + | /sbin/ldconfig & | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
fi | fi | ||
− | -# | + | -# Screen blanks after 15 minutes idle time, and powers down in one hour |
− | + | -# if the kernel supports APM or ACPI power management: | |
− | + | -/bin/setterm -blank 15 -powersave powerdown -powerdown 60 | |
− | + | ||
− | - | + | |
− | + | ||
− | - | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | - | + | |
- | - | ||
− | + | # Set the hostname. | |
− | + | if [ -r /etc/HOSTNAME ]; then | |
− | -/bin/ | + | /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .) |
− | + | @@ -109,13 +105,6 @@ | |
− | + | sh /etc/rc.d/rc.bluetooth start | |
− | + | ||
− | + | ||
− | @@ - | + | |
− | + | ||
fi | fi | ||
− | -# | + | -# Start wicd or networkmanager: |
− | + | -if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then | |
− | -if | + | - sh /etc/rc.d/rc.wicd start |
− | - | + | -elif [ -x /etc/rc.d/rc.networkmanager ]; then |
− | - | + | - sh /etc/rc.d/rc.networkmanager start |
− | + | ||
-fi | -fi | ||
- | - | ||
− | + | # Start networking daemons: | |
− | + | if [ -x /etc/rc.d/rc.inet2 ]; then | |
− | + | . /etc/rc.d/rc.inet2 | |
− | + | @@ -126,14 +115,6 @@ | |
− | + | . /etc/rc.d/rc.scanluns | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | - | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
fi | fi | ||
− | -# | + | -# Mount any additional filesystem types that haven't already been mounted: |
− | - | + | -mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done |
− | - | + | |
− | - | + | |
- | - | ||
− | -# | + | -# Start the Control Script for automounter: |
− | -if [ -x /etc/rc.d/rc. | + | -if [ -x /etc/rc.d/rc.autofs ]; then |
− | - sh /etc/rc.d/rc. | + | - sh /etc/rc.d/rc.autofs start |
-fi | -fi | ||
- | - | ||
− | # | + | # Start the Network Time Protocol daemon: |
− | if [ | + | if [ -x /etc/rc.d/rc.ntpd ]; then |
− | + | sh /etc/rc.d/rc.ntpd start | |
− | @@ - | + | @@ -153,16 +134,6 @@ |
− | + | chmod 755 / 2> /dev/null | |
− | + | chmod 1777 /tmp /var/tmp | |
− | -# | + | -# Start ACPI daemon. |
− | + | -if [ -x /etc/rc.d/rc.acpid ]; then | |
− | + | - . /etc/rc.d/rc.acpid start | |
− | -if [ - | + | |
− | - | + | |
− | + | ||
− | + | ||
-fi | -fi | ||
− | |||
- | - | ||
− | + | -# Enable CPU frequency scaling: | |
− | + | -if [ -x /etc/rc.d/rc.cpufreq ]; then | |
− | + | - . /etc/rc.d/rc.cpufreq start | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | -# | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | -if [ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | - | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
-fi | -fi | ||
- | - | ||
+ | # Update any existing icon cache files: | ||
+ | if find /usr/share/icons -maxdepth 2 2> /dev/null | grep -q icon-theme.cache ; then | ||
+ | for theme_dir in /usr/share/icons/* ; do | ||
diff -ruN rc.d-original/rc.inet2 rc.d/rc.inet2 | diff -ruN rc.d-original/rc.inet2 rc.d/rc.inet2 | ||
− | --- rc.d-original/rc.inet2 | + | --- rc.d-original/rc.inet2 2012-08-15 00:53:35.000000000 +0200 |
− | +++ rc.d/rc.inet2 | + | +++ rc.d/rc.inet2 2016-07-09 14:10:49.388841574 +0200 |
− | @@ -16, | + | @@ -16,51 +16,6 @@ |
# At this point, we are ready to talk to The World... | # At this point, we are ready to talk to The World... | ||
Line 715: | Line 455: | ||
-fi | -fi | ||
- | - | ||
− | + | -# If /etc/rc.d/rc.rpc is executable, run it to load rpc.portmap, rpc.lockd, | |
− | + | -# and rpc.statd. This might be needed to mount NFS partitions that are not | |
− | + | -# listed in /etc/fstab. Starting this twice won't hurt as the script will | |
− | + | -# check if things are already running before trying to start them. | |
− | + | -if [ -x /etc/rc.d/rc.rpc ]; then | |
− | + | - sh /etc/rc.d/rc.rpc start | |
− | + | -fi | |
+ | - | ||
-# Mount remote CIFS filesystems. Note that where possible, using CIFS is | -# Mount remote CIFS filesystems. Note that where possible, using CIFS is | ||
-# preferred over SMBFS. SMBFS is no longer actively maintained. | -# preferred over SMBFS. SMBFS is no longer actively maintained. | ||
Line 738: | Line 479: | ||
- /sbin/mount -v -t smbfs | - /sbin/mount -v -t smbfs | ||
-fi | -fi | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
== Contact == | == Contact == | ||
− | Comments and criticism can be addressed to roberto dot puzzanghera at sagredo dot eu ( | + | Comments and criticism can be addressed to roberto dot puzzanghera at sagredo dot eu (https://notes.sagredo.eu/other-contents-186/slackware-guest-on-linux-vserver-7.html) |
Latest revision as of 13:59, 21 July 2019
The purpose of this note is to setup a guest based on Slackware. What follows was tested on Slackware 14.2 to 13.1 (both 32b and 64b). I will assume that you have a Linux-Vserver box working.
Contents |
[edit] Download
wget https://notes.sagredo.eu/sites/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:
- PKG_LIST is the package list to be installed in the guest
- download_slack_pkg.sh is a script that you can use to download all the PKG_LIST. If you use this scriptlet all the package will be stored in the slackware[64]-version_pkg sub-folder.
- 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
- linux-vserver_slackware-14.2.patch is the patch which modify rc.0, rc.6 rc.M, rc.S, rc.inet2 and rc.syslog. It must be applyed after the creation of the vserver process. In the patch I switched off all the mounts and executable that are related to the hardware.
[edit] Download the packages
First of all select a minimal set of packages to be installed on the virtual server. This list of 123 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 460M 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 "14.2".
#!/bin/bash # # v. 2016.06.08 # Now the script parses comments in the package list (thanks to Mark Colclough) VERSION="14.2" # 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.slackware.no/slackware/slackware${ARCH}-${VERSION}/" # put here your pkg list LIST="${PWD}/PKG_LIST" # 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 # 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 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 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
NB: this script tries also to overwrite the packages downloaded from the /slackware folder with the updates belonging to the /patches dir.
[edit] 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 adjusting and running the script make_slack_vserver.sh:
#!/bin/bash # # v. 2016.07.05 # Author: Roberto Puzzanghera # Thanks to Mark Colclough for corrections # # This script installs a Slackware guest into a linux-vserver host (http://linux-vserver.org) # # Comments are welcome :-) # 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=test HOSTNAME=$NAME.YOURDOMAIN.XY IP=10.0.0.182 INTERFACE=eth0:$IP/24 CONTEXT=5182 VERSION=14.2 # 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="/usr/local/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 # 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} \ --context $CONTEXT \ --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 the /dev folder 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; ROOT=$VDIR/$NAME upgradepkg patches/*.t?z; echo "...done" echo echo read -p "press any key to copy the rc script to /etc/rc.d/init.d..." echo echo "copying rc to /etc/rc.d/init.d/rc" cp -p $RC $VDIR/$NAME/etc/rc.d/init.d/ echo "...done" echo echo "removing x flag to rc.sshd and rc.inetd, removing not needed rc scripts" chmod -x $VDIR/$NAME/etc/rc.d/rc.sshd $VDIR/$NAME/etc/rc.d/rc.inetd rm $VDIR/$NAME/etc/rc.d/rc.cpufreq $VDIR/$NAME/etc/rc.d/rc.modules* $VDIR/$NAME/etc/rc.d/rc.inet1* $VDIR/$NAME/etc/rc.d/rc.loop echo "...done" echo echo "trying to adjust 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 "...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 -n "Do you want that I apply the patch for you y/n? [y] " read VAR_PATCH if [ "$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 on http://notes.sagredo.eu/node/7" echo
[edit] Apply the patch
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-14.2.patch
Inside the tarball you can find the old patch for Slackware 14.1, 14.0, 13.37 and 13.1, if you like.
[edit] Post installation tasks
Put this inside your rc.local:
/usr/local/etc/rc.d/init.d/vprocunhide start
[edit] Start the new server
vserver <vserver_name> start vserver <vserver_name> enter
[edit] Patch applayed
diff -ruN rc.d-original/rc.6 rc.d/rc.6 --- rc.d-original/rc.6 2016-03-26 17:48:37.000000000 +0100 +++ rc.d/rc.6 2016-07-09 14:08:48.470713168 +0200 @@ -37,36 +37,6 @@ ;; esac -# Save the system time to the hardware clock using hwclock --systohc. -# This will also create or update the timestamps in /etc/adjtime. -if [ -x /sbin/hwclock ]; then - # Check for a broken motherboard RTC clock (where ioports for rtc are - # unknown) to prevent hwclock causing a hang: - if ! grep -q " : rtc" /proc/ioports ; then - CLOCK_OPT="--directisa" - fi - if [ /etc/adjtime -nt /etc/hardwareclock ]; then - if grep -q "^LOCAL" /etc/adjtime ; then - echo "Saving system time to the hardware clock (localtime)." - else - echo "Saving system time to the hardware clock (UTC)." - fi - /sbin/hwclock $CLOCK_OPT --systohc - elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then - echo "Saving system time to the hardware clock (UTC)." - if [ ! -r /etc/adjtime ]; then - echo "Creating system time correction file /etc/adjtime." - fi - /sbin/hwclock $CLOCK_OPT --utc --systohc - else - echo "Saving system time to the hardware clock (localtime)." - if [ ! -r /etc/adjtime ]; then - echo "Creating system time correction file /etc/adjtime." - fi - /sbin/hwclock $CLOCK_OPT --localtime --systohc - fi -fi - # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /etc/rc.d/rc.local_shutdown stop @@ -126,10 +96,6 @@ sleep $FUSER_DELAY fi -# Unmount any NFS, SMB, or CIFS filesystems: -echo "Unmounting remote filesystems:" -/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" - # Try to shut down pppd: PS="$(ps ax)" if echo "$PS" | /bin/grep -q -w pppd ; then @@ -215,22 +181,11 @@ # Before unmounting file systems write a reboot or halt record to wtmp. $shutdown_command -w -# Turn off swap: -echo "Turning off swap." -/sbin/swapoff -a -/bin/sync - # Stop cgmanager and cgproxy: if [ -x /etc/rc.d/rc.cgmanager ]; then sh /etc/rc.d/rc.cgmanager stop fi -echo "Unmounting local file systems:" -/bin/umount -v -a -t no,proc,sysfs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" 2> /dev/null - -echo "Remounting root filesystem read-only:" -/bin/mount -v -n -o remount,ro / - # This never hurts: /bin/sync @@ -288,12 +243,3 @@ fi fi fi - -# Now halt (poweroff with APM or ACPI enabled kernels) or reboot. -if [ "$shutdown_command" = "reboot" ]; then - echo "Rebooting." - /sbin/reboot -else - /sbin/poweroff -fi - diff -ruN rc.d-original/rc.M rc.d/rc.M --- rc.d-original/rc.M 2016-05-05 06:27:00.000000000 +0200 +++ rc.d/rc.M 2016-07-09 14:14:20.090096570 +0200 @@ -20,10 +20,6 @@ /sbin/ldconfig & fi -# Screen blanks after 15 minutes idle time, and powers down in one hour -# if the kernel supports APM or ACPI power management: -/bin/setterm -blank 15 -powersave powerdown -powerdown 60 - # Set the hostname. if [ -r /etc/HOSTNAME ]; then /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .) @@ -109,13 +105,6 @@ sh /etc/rc.d/rc.bluetooth start fi -# Start wicd or networkmanager: -if [ -x /etc/rc.d/rc.wicd -a -x /usr/sbin/wicd ]; then - sh /etc/rc.d/rc.wicd start -elif [ -x /etc/rc.d/rc.networkmanager ]; then - sh /etc/rc.d/rc.networkmanager start -fi - # Start networking daemons: if [ -x /etc/rc.d/rc.inet2 ]; then . /etc/rc.d/rc.inet2 @@ -126,14 +115,6 @@ . /etc/rc.d/rc.scanluns fi -# Mount any additional filesystem types that haven't already been mounted: -mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done - -# Start the Control Script for automounter: -if [ -x /etc/rc.d/rc.autofs ]; then - sh /etc/rc.d/rc.autofs start -fi - # Start the Network Time Protocol daemon: if [ -x /etc/rc.d/rc.ntpd ]; then sh /etc/rc.d/rc.ntpd start @@ -153,16 +134,6 @@ chmod 755 / 2> /dev/null chmod 1777 /tmp /var/tmp -# Start ACPI daemon. -if [ -x /etc/rc.d/rc.acpid ]; then - . /etc/rc.d/rc.acpid start -fi - -# Enable CPU frequency scaling: -if [ -x /etc/rc.d/rc.cpufreq ]; then - . /etc/rc.d/rc.cpufreq start -fi - # Update any existing icon cache files: if find /usr/share/icons -maxdepth 2 2> /dev/null | grep -q icon-theme.cache ; then for theme_dir in /usr/share/icons/* ; do diff -ruN rc.d-original/rc.inet2 rc.d/rc.inet2 --- rc.d-original/rc.inet2 2012-08-15 00:53:35.000000000 +0200 +++ rc.d/rc.inet2 2016-07-09 14:10:49.388841574 +0200 @@ -16,51 +16,6 @@ # At this point, we are ready to talk to The World... -# Mount remote (NFS) filesystems: -if cat /etc/fstab | grep -v '^#' | grep -w nfs 1> /dev/null 2> /dev/null ; then - # Start rpc.portmap, /sbin/rpc.lockd, and /sbin/rpc.statd if we find NFS - # volumes defined in /etc/fstab since these will need to be running in order - # to mount them. If they are not running, attempting to mount an NFS - # partition will cause mount to hang, or at least result in unreliable - # operation. Keep this in mind if you plan to mount unlisted NFS - # partitions... - # If you have uncommented NFS partitions in your /etc/fstab, rc.rpc is run - # whether it is set as executable or not. If you don't want to run it, - # comment the NFS partitions out in /etc/fstab or erase/rename rc.rpc. - if [ -r /etc/rc.d/rc.rpc ]; then - sh /etc/rc.d/rc.rpc start - fi - echo "Mounting remote (NFS) file systems: /sbin/mount -a -t nfs" - /sbin/mount -a -t nfs # This may be our /usr runtime! - # Show the mounted volumes: - /sbin/mount -v -t nfs -fi - -# If /etc/rc.d/rc.rpc is executable, run it to load rpc.portmap, rpc.lockd, -# and rpc.statd. This might be needed to mount NFS partitions that are not -# listed in /etc/fstab. Starting this twice won't hurt as the script will -# check if things are already running before trying to start them. -if [ -x /etc/rc.d/rc.rpc ]; then - sh /etc/rc.d/rc.rpc start -fi - -# Mount remote CIFS filesystems. Note that where possible, using CIFS is -# preferred over SMBFS. SMBFS is no longer actively maintained. -if cat /etc/fstab | grep -v '^#' | grep -w cifs 1> /dev/null 2> /dev/null ; then - echo "Mounting remote CIFS file systems: /sbin/mount -a -t cifs" - /sbin/mount -a -t cifs - # Show the mounted volumes: - /sbin/mount -v -t cifs -fi - -# Mount remote SMB filesystems: -if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null ; then - echo "Mounting remote SMBFS file systems: /sbin/mount -a -t smbfs" - /sbin/mount -a -t smbfs - # Show the mounted volumes: - /sbin/mount -v -t smbfs -fi
[edit] Contact
Comments and criticism can be addressed to roberto dot puzzanghera at sagredo dot eu (https://notes.sagredo.eu/other-contents-186/slackware-guest-on-linux-vserver-7.html)