wiki:install_vserver

Install a vserver

The steps below have been incorporated into a script called vserver-create which is in the root directory of our vserver host files.

In this example, we're creating a new server called jacobo on the physical server called ottorene. Change jacobo and ottorene to names relevant to your server.

  • Create a disk (or disks) to be used by the vserver
    lvcreate --name jacobo_root --size 1G vg_ottorene0
    
  • Create a filesystem
    mkfs -t ext3 /dev/mapper/vg_ottorene0-jacobo_root
    
  • Add the new disk to fstab so it is mounted on boot
    echo /dev/mapper/vg_ottorene0-jacobo_root /var/lib/vservers/jacobo ext3 defaults 0 2 >> /etc/fstab
    
  • Make the target directory and mount it
    mkdir /var/lib/vservers/jacobo
    mount /var/lib/vservers/jacobo
    
  • Create the vserver. Replace the context number with a number unique to the server
    vserver jacobo build -m debootstrap --context 201 --hostname jacobo --interface eth0:209.234.253.167/27 --initstyle plain -- -d lenny -m http://ftp.us.debian.org/debian -- --include less,psmisc,lsof,socat,emacs22-nox,emacs22-bin-common,emacs22-common,liblockfile1,emacsen-common,bsdmainutils,locales --keyring=/usr/share/keyrings/debian-archive-keyring.gpg
    
  • Ensure that the server starts on boot
    echo default > /etc/vservers/jacobo/apps/init/mark
    
  • Manually start the vserver
    vserver jacobo start
    
  • Ensure that it started
    vserver-stat 
    
  • Enter the vserver
    vserver jacobo enter
    

Here's the output of a full session:

0 ottorene:~# lvcreate --name zimmerman_root --size 1G vg_ottorene0
  Logical volume "zimmerman_root" created
0 ottorene:~# mkfs -t ext3 /dev/mapper/vg_ottorene0-zimmerman_root 
mke2fs 1.41.2 (02-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
0 ottorene:~# echo /dev/mapper/vg_ottorene0-zimmerman_root /var/lib/vservers/zimmerman ext3 defaults 0 2 >> /etc/fstab
0 ottorene:~# mkdir /var/lib/vservers/zimmerman
0 ottorene:~# mount /var/lib/vservers/zimmerman
0 ottorene:~# vserver zimmerman build -m debootstrap --context 101 --hostname zimmerman --interface eth0:209.234.253.170/27 --initstyle plain -- -d lenny -m http://ftp.us.debian.org/debian -- --include less,psmisc,lsof,socat,emacs22-nox,emacs22-bin-common,emacs22-common,liblockfile1,emacsen-common,bsdmainutils,locales --keyring=/usr/share/keyrings/debian-archive-keyring.gpg

0 ottorene:~# vserver-stat 
CTX   PROC    VSZ    RSS  userTIME   sysTIME    UPTIME NAME
0 ottorene:~# cat /etc/vservers/zimmerman/apps/init/mark
cat: /etc/vservers/zimmerman/apps/init/mark: No such file or directory
1 ottorene:~# echo default > /etc/vservers/zimmerman/apps/init/mark
0 ottorene:~# vserver zimmerman start
Mount failed for selinuxfs on /selinux:  Operation not permitted
0 ottorene:~# vserver-stat 
CTX   PROC    VSZ    RSS  userTIME   sysTIME    UPTIME NAME
101      4 122.8M     2M   0m00s32   0m00s24   0m20s17 zimmerman
0 ottorene:~# vserver zimmerman enter

Last modified 10 years ago Last modified on May 7, 2009, 9:20:20 AM