RE: [Vserver] vserver@crux

From: <smagnuson_at_forzani.com>
Date: Thu 13 Apr 2006 - 15:43:42 BST
Message-ID: <511A30B014A7DF42902B680EA85C07DC089E5106@CALMAIL01.fglcorporate.net>

Falk,

Not sure if this helps any but I have a newer doc version. Pasted it
below. I have not tried with crux 2.2 yet.

Later
Sig

How to install and use linux-vserver with crux 2.0 / 2.1
http://crux.nu/
http://linux-vserver.org/
http://gentoo.home.xnull.de/doc/en/vshandbook/index.xml?part=0&chap=0

notes:
Expect to find errors
I may be doing things completely backwards but it seems to work
vservers are going to be installed onto seperate partition /vservers/...
I use sudo for most root commands. If you prefer to use root then ignore
sudo at front of commands

Preparing your host server with vserver

    * Get vserver code

cd ~/src/vserver
wget
http://www.13thfloor.at/vserver/d_rel26/v1.9.5/util-vserver-0.30.204.tar
.gz
gzip -d util-vserver-0.30.204.tar.gz
tar -xf util-vserver-0.30.204.tar

wget
http://www.13thfloor.at/vserver/d_rel26/v1.9.5/linux-vserver-1.9.5.tar.g
z
gzip -d linux-vserver-1.9.5.tar.gz
tar -xf linux-vserver-1.9.5.tar

    * Get vanilla linux kernel and compile in vserver patch aquired from
above

cd /usr/src
sudo wget
ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.11.5.tar.bz2
sudo bzip2 -d linux-2.6.11.5.tar.bz2
tar -xf linux-2.6.11.5.tar

cd linux-2.6.11.5
sudo cp ../linux-2.6.6/.config .
sudo cp ~/src/vserver/patch-2.6.11.5-vs1.9.5.diff
sudo patch -p1 -s <../patch-2.6.11.5-vs1.9.5.diff

If you want: patch for the specific kernel

sudo make menuconfig
sudo make all
sudo make modules_install

    * Install newly patched kernel

cd /usr/src
sudo rm linux
sudo ln -s linux-2.6.11.5 linux

sudo cp /usr/src/linux-2.6.11.5/arch/i386/boot/bzImage
/boot/vmlinuz-2.6.11.5-1
sudo cp System.map /boot/System.map-2.6.11.5-1
cd /boot
sudo ls -s System.map-2.6.6-2 System.map

sudo vi /etc/lilo.conf
...
...
image=/boot/vmlinuz-2.6.11.5-1
label=KERNEL-4
root=/dev/discs/disc0/part2
read-only

sudo lilo -q
sudo lilo
sudo lilo -q

    * Install additional/required software

sudo prt-get install iproute2
sudo prt-get install iptables
sudo prt-get install rsync
sudo prt-get install dietlibc

    * Get vconfig binary

cd ~/src/
wget http://www.candelatech.com/~greear/vconfig
sudo cp vconfig /usr/local/sbin

    * Complile and install vserver utilities

cd ~/src/vserver/util-vserver-0.30.204
./configure --prefix=/usr/local
make
sudo make install

    * Create vserver guest OS directory

sudo mkdir -m 000 /vservers
sudo mkdir /vservers/vcrux01

    * If using SSH (or any other port listening application) change it
to listen to the specific interface (ie not 0.0.0.0)

sudo vi /etc/ssh/sshd_config
...
...
ListenAddress 172.27.12.19
...
...

    * restart ssh and ensure it still works

sudo /etc/rc.d/sshd restart

Building your first vserver

    * On Host OS

sudo vserver vcrux01 build -m skeleton -n vcrux01 --context 100
--hostname vcrux01.corporate.net --interface 172.27.12.24 --netdev eth0
--netmask 255.255.248.0 --initstyle plain

    * Edit sysctl.conf and configure vshelper

sudo vi /etc/sysctl.conf
kernel.vshelper = /usr/local/lib/util-vserver/vshelper

    * Set up vserver barrier (this is untested)

sudo showattr -d /vservers/vcrux01/..
---bui- /vservers/vcrux01/..
sudo setattr --barrier /vservers/vcrux01/..
sudo showattr -d /vservers/vcrux01/..
---Bui- /vservers/vcrux01/..

    * Try this if the above does not work (This works but above should
be better)

#sudo showattr -d /vservers/vcrux01
#---bui- /vservers/vcrux01
#sudo setattr --barrier /vservers/vcrux01
#sudo showattr -d /vservers/vcrux01
#---Bui- /vservers/vcrux01

    * set default tty (not sure if this works)

sudo mkdir -p /usr/local/etc/vservers/.defaults/apps/init
cd /usr/local/etc/vservers/.defaults/apps/init
sudo ln -s /dev/tty6 tty

    * Check the folowing file to ensure all it configured fine. If not
edit files.

cat /usr/local/etc/vservers/vcrux01/apps/init/style
plain

cat /usr/local/etc/vservers/vcrux01/interfaces/dev
eth0

cat /usr/local/etc/vservers/vcrux01/interfaces/mask
255.255.248.0

cat /usr/local/etc/vservers/vcrux01/interfaces/0/ip
172.27.12.24

cat /usr/local/etc/vservers/vcrux01/interfaces/0/name
c01

cat /usr/local/etc/vservers/vcrux01/uts/nodename
vcrux01.corporate.net

cat /usr/local/etc/vservers/vcrux01/name
vcrux01

cat /usr/local/etc/vservers/vcrux01/fstab
none /proc proc defaults 0 0
none /tmp tmpfs size=16m,mode=1777 0 0
none /dev/pts devpts gid=5,mode=620 0 0

cat /usr/local/etc/vservers/crux01/context
100

# set it up so uptime is reflective of vserver uptime not host uptime
cat /usr/local/etc/vservers/unixdev1/flags
VIRT_UPTIME

Install Crux to /vserver/vcrux01

boot from crux install cd
mount /, /usr, and /vservers to /mnt, /mnt/usr, and /mnt/vservers
chroot to /mnt
set root password
run crux setup
use /mnt/vservers/vcrux01 as install point
do not compile kernel, not used
do not run lilo
do not run lilo
do not run lilo
see crux handbook for details: http://crux.nu/doc/handbook.html

 

boot OS back up

    * configure guest OS vcrux01

cd /mnt/vservers/vcrux01

sudo vi ./etc/rc.conf
TIMEZONE=Canada/Mountain
HOSTNAME=vcrux01
SERVICES=(crond sshd)

sudo rm -f ./etc/mtab
sudo vi ./etc/mtab
/dev/hdv1 / ufs rw 0 0
sudo chmod 644 ./etc/mtab

sudo vi ./etc/rc

At the very least comment out:
/bin/rm -f /etc/mtab*

cat /dev/null > ./etc/fstab

sudo vi ./etc/hosts.allow
sshd:all

cat /dev/null > ./etc/rc.d/net

sudo vi ./etc/resolve.conf
domain corporate.net
search corporate.net
nameserver 172.27.8.42
nameserver 172.27.8.43

sudo vi ./etc/inittab
#c1:2:respawn:/sbin/agetty 38400 vc/1 linux
#c2:2:respawn:/sbin/agetty 38400 vc/2 linux
#c3:2:respawn:/sbin/agetty 38400 vc/3 linux
#c4:2:respawn:/sbin/agetty 38400 vc/4 linux
#c5:2:respawn:/sbin/agetty 38400 vc/5 linux
#c6:2:respawn:/sbin/agetty 38400 vc/6 linux

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now

sudo chmod 0666 ./dev/tty

Start your vserver

    * On host OS

sudo /usr/local/lib/util-vserver/vprocunhide

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 32 33.5M 3K 0m07s48 0m09s62 13h50m14 root server

sudo vserver vcrux01 start

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 32 33.5M 3K 0m07s48 0m09s62 13h50m14 root server
100 4 7.4M 769 0m00s72 0m00s71 13h49m58 vcrux01

    * Enter vserver and complete setup

sudo vserver vcrux01 enter

/usr/bin/newaliases

setup crux ports (using httpup (curl and httpup) if necessary) and
update ports
see crux handbook for details: http://crux.nu/doc/handbook.html

Creating your 2nd, 3rd, nth vserver

    * On host OS copy existing vserver

sudo vserver vcrux01 stop
sudo vserver vcrux02 build -m skeleton -n vcrux02 --context 200
--hostname vcrux02.corporate.net --interface xxx.xxx.xxx.xxx --netdev
eth0 --netmask 255.255.248.0 --initstyle plain
sudo rm -rf /vservers/vcrux02
sudo cp -va /vservers/vcrux01 /vservers/vcrux02
OR
sudo rsync -av /vservers/vcrux01/ /vservers/vcrux02

cat /usr/local/etc/vservers/vcrux02/apps/init/style
plain

cat /usr/local/etc/vservers/vcrux02/interfaces/dev
eth0

cat /usr/local/etc/vservers/vcrux02/interfaces/mask
255.255.248.0

cat /usr/local/etc/vservers/vcrux02/interfaces/0/ip
172.27.12.40

cat /usr/local/etc/vservers/vcrux02/interfaces/0/name
c02

cat /usr/local/etc/vservers/vcrux02/uts/nodename
vcrux02.corporate.net

cat /usr/local/etc/vservers/vcrux02/name
vcrux02

cat /usr/local/etc/vservers/vcrux02/fstab
none /proc proc defaults 0 0
none /tmp tmpfs size=16m,mode=1777 0 0
none /dev/pts devpts gid=5,mode=620 0 0

cat /usr/local/etc/vservers/vcrux02/context
200

# set it up so uptime is reflective of vserver uptime not host uptime
cat /usr/local/etc/vservers/vcrux02/flags
VIRT_UPTIME

sudo vi /vservers/vcrux02/etc/rc.conf
HOSTNAME=vcrux02

    * Set up vserver barrier

sudo showattr -d /vservers/vcrux02/..
---bui- /vservers/vcrux02/..
sudo setattr --barrier /vservers/vcrux02/..
sudo showattr -d /vservers/vcrux02/..
---Bui- /vservers/vcrux02/..

    * If vhost is Redhat AS 3.0 also look at that following

sudo vi /vservers/caloratst01/etc/resolv.conf
sudo vi /vservers/caloratst01/etc/fstab
sudo vi /vservers/caloratst01/etc/hosts
sudo vi /vservers/caloratst01/etc/ssh/sshd_config
X11UseLocalhost no - Needed for vserver x forwarding
sudo vi /vservers/caloratst01/etc/sysconfig/network
set hostname
sudo vi /vservers/caloratst01/etc/rc.sysinit
remove mtab references
remove tty references
sudo vi /vservers/caloratst01/etc/inittab
remove tty references
check over /usr/local/etc/vservers/caloratst01/..

    * Start your new vserver

sudo /usr/local/lib/util-vserver/vprocunhide

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 32 33.5M 3K 0m07s48 0m09s62 13h50m14 root server

sudo vserver vcrux01 start
sudo vserver vcrux02 start

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 32 33.5M 3K 0m07s48 0m09s62 13h50m14 root server
100 4 7.4M 769 0m00s72 0m00s71 13h49m58 vcrux01
200 4 7.4M 769 0m00s83 0m00s93 13h55m46 vcrux02

    * Enter vserver and complete setup

sudo vserver vcrux02 enter

How I'm starting/stopping vservers at boot time

    * On host OS

sudo vi /etc/rc.conf
SERVICES=(net crond sshd vcrux01 vcrux02 vcrux03)

sudo vi /etc/rc.d/vcrux01

#!/bin/sh
#
# /etc/rc.d/vserver: start/stop vservers
#
VSERVER=vcrux01

case $1 in
start)
/usr/local/lib/util-vserver/vprocunhide
/usr/local/sbin/vserver $VSERVER start
;;
stop)
/usr/local/sbin/vserver $VSERVER stop
;;
status)
/usr/local/sbin/vserver-stat
;;
*)
echo "usage: $0 [start|stop|status]"
;;
esac

# End of file

Common commands I'm using

    * On the Host OS

sudo /usr/local/lib/util-vserver/vprocunhide

This command makes available some areas of /proc to verserver. Only need
to run once per boot.

sudo /usr/local/sbin/vserver vcrux01 start

Start vcrux01 vserver

sudo /usr/local/sbin/vserver vcrux01 stop

Stop vcrux01 vserver

sudo /usr/local/sbin/vserver vcrux01 enter

Enter vcrux01 vserver

sudo /usr/local/sbin/vserver vcrux01 exec ps -aef
sudo /usr/local/sbin/vserver vcrux01 exec uname -a

vserver exec command. Runs specified command on specified vserver

sudo /usr/local/sbin/vserver-stat

Displays status of running ververs

sudo /usr/local/sbin/vserver-info

Displays build/versioning info of verserver install

sudo /usr/local/sbin/vps -ef

vserver ps command

sudo /usr/local/sbin/vtop

vserver top command

sudo /usr/local/sbin/vuname --xid 100

vserver uname command. Displays uname of vserver with context ID

 

more commands in /usr/local/sbin/ and /usr/local/lib/util-vserver/

    * Killing a vserver instance

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 48 55.4M 17.9M 1m10s53 0m51s70 1d10h07 root server
10 1 1.4M 496K 0m00s20 0m00s12 1d10h06 vcruxtemplate01

sudo vkill --help
Usage: vkill [--xid|-c <xid>] [-s <signal>] [--] <pid>*

sudo vkill --xid 10 -s 9 -- 1

sudo vserver-stat
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 32 34.1M 12.9M 1m10s58 0m51s26 1d10h07 root server

Migrating/cloning/moving vservers between hosts

    * Clone host1:vserver1 to host2:vserver1 but use different vserver
name IP's, etc

unixdev2:vcruxtemplate02 --> unixdev3:vcruxtemplate01
stop vserver(s) to be cloned

ssh unixdev3
sudo /etc/rc.d/rsyncd start
sudo vserver vcruxtemplate01 build -m skeleton -n vcruxtemplate01
--context 10 --hostname vcruxtemplate01.corporate.net --interface
172.27.10.203 --netdev eth0 --netmask 255.255.248.0 --initstyle plain

ssh unixdev2
sudo rsync -avz /vservers/vcruxtemplate02/
172.27.10.206:/vservers/vcruxtemplate01

sudo vi /vservers/vcruxtemplate01/etc/rc.conf

check over /usr/local/etc/vservers/vcruxtemplate01/..

 

    * Exact Clone host1:vserver1 to host2:vserver1

unixdev2:vcrux02 --> unixdev3:vcrux02
stop vserver(s) to be cloned

ssh unixdev3
sudo /etc/rc.d/rsyncd start

ssh unixdev2
sudo rsync -avz /usr/local/etc/vservers/vcrux02
172.27.10.206:/usr/local/etc/vservers
sudo rsync -avz /vservers/vcrux02 172.27.10.206:/vservers

Creating a vserver from a non-vserver host

    * Clone host1 (non-vserver) to host1:vserver1

calcrs03 --> calvunix02:rhas3template01

ssh calvunix02
sudo /etc/rc.d/rsyncd start
sudo vserver vrhas3template01 build -m skeleton -n vrhas3template01
--context 30 --hostname vrhas3template01.corporate.net --interface
172.27.10.206 --netdev eth0 --netmask 255.255.248.0 --initstyle plain

ssh calcrs03
cat /home/sig/rsync-exclude.txt
/u01/
/u02/
/u03/
/u04/
/u05/
/u06/
/u07/
/u08/
/u09/
/u10/
/u11/
/u99/
/unix_data/
/proc/
/dev/
/boot/

sudo rsync -avz -e ssh --exclude-from=/home/sig/rsync-exclude.txt /
172.27.10.209:/vservers/vrhas3template01

ssh calvunix02
sudo vi /vservers/vrhas3template01/etc/resolv.conf
sudo vi /vservers/vrhas3template01/etc/fstab
sudo vi /vservers/vrhas3template01/etc/hosts
sudo vi /vservers/vrhas3template01/etc/ssh/sshd_config
X11UseLocalhost no - Needed for vserver x forwarding
sudo vi /vservers/vrhas3template01/etc/sysconfig/network
set hostname
sudo vi /vservers/vrhas3template01/etc/rc.sysinit
remove mtab references
remove tty references
sudo vi /vservers/vrhas3template01/etc/inittab
remove tty references
check over /usr/local/etc/vservers/vrhas3template01/..

sudo vserver vrhas3template01 start
sudo vserver-stat
sudo vserver vrhas3template01 enter

Mount NFS filesystem inside vserver

    * On NFS server (non vserver)

added vserver host/root system ip address to nfs shares
ie:
sudo vi /etc/exports
/nfs_unix_data calnfs01.corporate.net(rw,sync,insecure,no_root_squash)

sudo exportfs
sudo exportfs -ra (to reread your config changes)
sudo exportfs

    * On vserver host/root system

start portmap
start rpc.statd

sudo vi /usr/local/etc/vservers/unixdev1/fstab
calnfs01.corporate.net:/nfs_unix_data /unix_data nfs hard,intr,nolock 0
0

#ccapabilities are set as follows
cat /usr/local/etc/vservers/unixdev1/ccapabilities
SECURE_MOUNT
SECURE_REMOUNT
BINARY_MOUNT

sudo vserver unixdev1 stop
sudo vserver unixdev1 start
sudo vserver unixdev1 enter

#It is viewable through the vserver and usable.

#I re-mount this filesystem manually without a vserver restart from the
root/host

sudo vnamespace -e 100 mount -t nfs
calnfs01.corporate.net:/nfs_unix_data /vservers/unixdev1/unix_data

 

#I can unmount this filesystem manually without a vserver restart from
the root/host

sudo vnamespace -e 100 umount /vservers/unixdev1/unix_data

 

It may look a little screwy when doing manual mounts (df -h) but it
works. When the vserver is restarted all looks right again.

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hdv1 58G 8.0G 47G 15% /
none 64M 0 64M 0% /tmp
calnfs01.corporate.net:/nfs_unix_data 100G 406M 100G 1% /unix_data

-----Original Message-----
From: vserver-bounces@list.linux-vserver.org
[mailto:vserver-bounces@list.linux-vserver.org] On Behalf Of Falk Hamann
Sent: Thursday, April 13, 2006 6:03 AM
To: vserver@list.linux-vserver.org
Subject: [Vserver] vserver@crux

I read the manual to install vserver on crux.
http://list.linux-vserver.org/archive/vserver/msg09371.html
I followed each step. But starting vserver fails.

# vserver vcrux01 start
save_ctxinfo: open("/usr/var/run/vservers/vcrux01"): No such file or
An error occured while executing the vserver startup sequence; when
there are no other messages, it is very likely that the init-script
(/sbin/init) failed.

Common causes are:
* /etc/rc.d/rc on Fedora Core 1 and RH9 fails always; the 'apt-rpm'
build method knows how to deal with this, but on existing installations,
  appending 'true' to this file will help.

Failed to start vserver 'vcrux01'

The file "run" in config-directory is an symbolic dead-link.

# ls -l /etc/vservers/vcrux01/run
lrwxrwxrwx 1 root root 29 Apr 10 17:24 /etc/vservers/vcrux01/run
-> /usr/var/run/vservers/vcrux01

This is exactly, what I found in the documentation of source
save_ctxinfo.c.
// Saves current ctx + vserver-info into 'argv[1] + /run' which must be
a dead // symlink

What goes wrong ?
Thanks Falk

PS: The configure-options are:
    ./configure --prefix=/usr \
                --sysconfdir=/etc \
                --with-initrddir=/etc/rc.d
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver

_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Thu Apr 13 15:45:44 2006

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 13 Apr 2006 - 15:45:50 BST by hypermail 2.1.8