About this list Date view Thread view Subject view Author view Attachment view

From: Sam Vilain (sam_at_vilain.net)
Date: Tue 24 Jun 2003 - 13:29:58 BST


On Sun, 22 Jun 2003 11:48, you wrote:
> - unification can not be used across devices
>
> what does that mean? again you lose memory and
> performance, because libraries and common
> executables can not be shared amongh vservers
> (this holds for loop and lvm)

Perhaps not, but you can unify just the pieces that need unification;
/usr, /lib, etc.

Consider the situation where you have an LVM partition /vservers, ext2
or ext3 - say, 2GB. This holds all the vserver's OS images - those
most suitable for unification. Each vserver has its own LVM parition,
/vservers/foobar, reiserfs (so it may be easily resized).

The following script, shade-vserver.sh, run after building a vserver
using "debootstrap" or similar will `shade' the vserver's crucial
pieces:

-----shade-vserver.sh
#!/bin/sh

umask 022
VSERVER=$1

if [ -z "$VSERVER" ]
then
        echo "Usage: $0 vserver"
        exit 1
fi

if [ ! -d /vservers/$VSERVER -o ! -f /etc/vservers/$VSERVER.conf ]
then
        echo $VSERVER does not appear to exist
        exit 1
fi

if [ -d /vservers/shadow/$VSERVER ]
then
        echo $VSERVER appears to already be shady
        exit 1
fi
mkdir /vservers/shadow/$VSERVER

if [ "`expr \"\`vserver $VSERVER status\`" : 'is running'`" -ne 0 ]
then
        echo Stopping vserver $VSERVER...
        vserver $VSERVER stop
        START=1
fi

echo -n "Shading $VSERVER..."
set -e
for x in usr bin lib sbin
do
        echo -n " /$x"
        mv /vservers/$VSERVER/$x /vservers/shadow/$VSERVER/
        mkdir /vservers/$VSERVER/$x
done
echo " done."

cd /vservers/shadow
echo "Unifying files..."
/usr/lib/vserver/unify-dirs -il *

if [ -n "$START" ]
then
        echo "Starting vserver $VSERVER..."
        vserver $VSERVER start
fi
-----
The `unify-dirs' script is mine, at
http://www.vilain.net/vserver/unify-dirs

You'll also need to replace two functions in /usr/sbin/vserver with
these versions:

mountproc()
{
        mkdir -p $1/proc $1/dev/pts
        if [ ! -d $1/proc/1 ] ; then
                mount -n -t proc none $1/proc
                mount -n -t devpts none $1/dev/pts
        fi
        if [ ! -d $1/usr/bin -a -d shadow/$1/usr ]
        then
                mount -n --bind shadow/$1/usr $1/usr
                mount -n --bind shadow/$1/bin $1/bin
                mount -n --bind shadow/$1/lib $1/lib
                mount -n --bind shadow/$1/sbin $1/sbin
        fi
}
umountproc()
{
        umount $1/proc 2>/dev/null
        umount $1/dev/pts 2>/dev/null
        umount $1/usr 2>/dev/null
        umount $1/bin 2>/dev/null
        umount $1/sbin 2>/dev/null
        umount $1/lib 2>/dev/null
}

Personally, I think that at least this or some close analogue should
go in the distributed vserver script, as it is a small change, generic
and will only be used if the shading is present.

I've put all the related scripts at http://vilain.net/vserver/

--
Sam Vilain, sam_at_vilain.net

Real computer scientists love the concept of users. Users are always real impressed by the stuff computer scientists are talking about; it sure sounds better than the stuff they are being forced to use now.


About this list Date view Thread view Subject view Author view Attachment view
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Tue 24 Jun 2003 - 13:58:50 BST by hypermail 2.1.3