We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

CentOS 4 VServer How To

(originally based off of the Fedora Core 3 How To)

This will guide you through the process of setting up Linux-VServer on CentOS 4, meaning turning it into a host and creating different types of vservers on that host.

A. Requirements

  1. What do I need to get started?
    • CentOS 4 installed, but not yet in production
    • Internet connection for downloads
  2. Do I have to have multiple offical IP Addresses?
    • No, this document uses all internal IP addresses for demonstration purposes. When going into production, see other docs for the method you choose to use.

B. New VServer-enabled kernel

  1. Get and compile kernel
The CentOS default Kernel release is highly patched already and thus are not compatible with the patches supplied by linux-vserver.org. For this reason, we are going to use a vanilla-kernel (read: an unmodified original linux kernel) from kernel.org.
  • Go to /pub/linux/kernel/v2.6/
  • Get the latest linux-2.6.??.tar.bz2 ( where ?? is the kernel subversion, by the time of this writing, the latest is 2.6.11.5)
  • Get the matching .sign file
  • Once both files are downloaded, verify the pgp signature of the archive:
  • Add the linux kernel OpenPGP signature to your local gpg by running gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E
  • Now verify the kernel: gpg --verify linux-2.6.??.tar.bz2.sign linux-2.6.??.tar.bz2 ( for more details about this, visit [Kernel.org])
  • Move the kernel archive to /usr/src (mv linux-2.6.??.tar.bz2 /usr/src/) and unpack it (tar -xjf linux-2.6.??.tar.bz2)
  • Donwload [the Patchset] now (by the time of this writing, the latest version is 1.9.5 against kernel 2.6.11.5)
  • Run the patch against the kernel from within /usr/src ( patch -p0 < patch-2.6.??-vs1.9.5.diff )
  • Now enter the linux-2.6.?? source directory and run make menuconfig. You need to make sure all the required vserver options are enabled, besides that, build a kernel as usual.
  • Next, run 'make', then 'make modules_install', then 'make install'
  • CentOS, properly modifies the grub.conf file for the new kernel, but we still need to make some more changes:
  1. Fix /etc/fstab
  • CentOS uses LABEL, which is not compatible with a vanilla kernel
  • Run 'mount' to see what drives are pointing where
  • Change the corresponding lines in /etc/fstab to point to the real device name:
Before:
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot1            /boot                   ext2    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-hda2         swap                    swap    defaults        0 0
/dev/hdb                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0
Mount:
/dev/hda3 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/hda1 on /boot type ext2 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
After:
/dev/hda3               /                       ext3    defaults        1 1
/dev/hda1               /boot                   ext2    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0
/dev/hdb                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0

3. Fix /boot/grub/grub.conf

* This file also needs to be modified for the same reasons

* Change all lines that use LABEL in /boot/grub/grub/conf to point to the real device name

Example:

Change:

kernel /vmlinuz-2.6.9-5.0.3.EL ro root=LABEL=/

To:

kernel /vmlinuz-2.6.9-5.0.3.EL ro root=/dev/hda1

4. Disable SELinux

SELinux conflicts with Linux-VServer. Disable it in /etc/selinux/config (SELINUX=disabled)

5. Reboot

If it boots, you did it right, otherwise, go back and check everything.

C. Get the tools

* Download [util-vserver](v0.30.205)

* Configure it with the following options:

./configure prefix=/usr sysconfdir=/etc --with-vrootdir=/vservers

* make, make check, make install

D. Adding CentOS? 4 Support into the tools

* cd /usr/lib/util-vserver/distributions

* cp fc3 centos4

* cd centos4

* mkdir pubkeys

* cp /usr/share/rhn/RPM-GPG-KEY-centos4 ./pubkeys/ (Should be there from a properly updated CentOS? install)

* ln -s ../redhat/initpre .

* ln -s ../redhat/initpost .

* cd pkgs

* rm -f 01 02 03

* vi 01 and put the contents of this into it: http://linux-vserver.org/CentOS_min_install

* cd ../yum

* vi yu/yum.conf and replace with:

[main]

cachedir=@YUMCACHEDIR@

reposdir=@YUMETCDIR@/yum.repos.d

debuglevel=2

logfile=@YUMLOGDIR@/log

pkgpolicy=newest

distroverpkg=centos-release

tolerant=1

exactarch=1

retries=20

obsoletes=1

gpgcheck=1

* cd yum.repos.d

* rm -f *.repo

* cp /etc/yum.repos.d/CentOS?-Base.repo .

E. VServer creation

1. Build a new vserver