Disclaimer: this is an unsupported software, which was written to ease some pain with userspace installation. It is designed solely for developer testing.

Introduction

Did you ever have to build the same package in SLC3 and SLC4 environments? And your desktop might not run either of them? Did you try using virtualization (for example VMware or Xen), but hit memory/disk/CPU limits?

You might try using a chroot environment then!

Chroot environment is basically a complete OS installation in a subdirectory, however it uses the same kernel, same memory, same process space and same network resources as the "hosting" OS. It simply changes the / to this subdirectory.

How to use it

Download an OS image for building

To simplify your life there are some chroot environment tarballs at lxtank02.cern.ch. You can fetch some images prepared for gLite builds directly:

You can also create custom images by VNode.

Once you have the tarball, you need to extract it and customize your startup script:

  mkdir /var/chroot
  cd /var/chroot
  wget http://lxtank02.cern.ch/chroot/SLC4-chroot-master.tgz
  mkdir SLC4
  cd SLC4
  tar -xzf ../SLC4-chroot-master.tgz
  mkdir media mnt proc sys srv tmp
  chmod 1777 tmp
  cd ..

  wget http://lxtank02.cern.ch/chroot/SLC3-chroot-master.tgz
  mkdir SLC3
  cd SLC3
  tar -xzf ../SLC3-chroot-master.tgz
  mkdir media mnt proc sys srv tmp
  chmod 1777 tmp
  cd ..

Download an OS image for testing

There are some extremely small OS images for network boots from u-boot, which you can use for deployment tests:

cd /var/chroot
wget http://lxservb03/u-boot/u-slc5-x86_64-test/u-root.cpio.gz
mkdir slc5
cd slc5
zcat ../u-root.cpio.gz | cpio -iv

RedHat based hosting environment

  wget http://lxtank02/chroot/chroot-envs-0.6.0-1.noarch.rpm
  rpm -ivh chroot-envs-0.6.0-1.noarch.rpm
  chkconfig --add chroot-envs
  service chroot-envs start

Please check the repository for updates!

Debian based hosting environment

  wget http://lxtank02/chroot/chroot-envs_0.6.0-1_all.deb
  dpkg -i chroot-envs_0.6.0-1_all.deb
  update-rc.d chroot-envs defaults 90 18
  /etc/init.d/chroot-envs start

Please check the repository for updates!

Ubuntu based hosting environment

Using the repository of http://ubuntu.cern.ch you can simply install it:

  apt-get install chroot-envs

Adding users

To be able to edit the files directly in the chroot envs it is useful add your user as native user to the OS images. You can do that by editing the passwd, shadow, group and gshadow files in the OS images, or running the following command:

  chroot-envs-create-user  bob

SSH configuration

Please do not forget to edit your firewall rules that the ssh ports (2223 and 2224) of the chroot environments are not exposed!

If everything went well, there is an sshd running in your chroot environment, which you can connect to, as if it was on a different machine.

To avoid confusion with other ssh daemons on the same IP address, you may add it to your .ssh/config:

Host slc3
    ForwardX11 yes
    ForwardAgent yes
    UserKnownHostsFile ~/.ssh/chroot-slc3-known_hosts
    Hostname 127.0.0.1
    Port 2223
    GSSAPIAuthentication no
    GSSAPIDelegateCredentials no
    PubkeyAuthentication yes
Host slc4
    ForwardX11 yes
    ForwardAgent yes
    UserKnownHostsFile ~/.ssh/chroot-slc4-known_hosts
    Hostname 127.0.0.1
    Port 2224
    GSSAPIAuthentication no
    GSSAPIDelegateCredentials no
    PubkeyAuthentication yes
Host sl5
    ForwardX11 yes
    ForwardAgent yes
    UserKnownHostsFile ~/.ssh/chroot-sl5-known_hosts
    Hostname 127.0.0.1
    Port 2226
    GSSAPIAuthentication no
    GSSAPIDelegateCredentials no
    PubkeyAuthentication yes

You can also generate these entries using /usr/bin/chroot-envs-ssh-config.

At this point you can simply do an 'ssh root@slc4', 'ssh root@slc3' or 'ssh root@sl5' to log into your environment (the initial password is "root").

In case you want to change the root password of the chroot image:

  chroot /var/chroot/sl5
  passwd
  exit

How to use AFS?

We assume that AFS is properly configured in the hosting environment.

The chroot environment needs to have at least 'klog' utility to authenticate with AFS. In SLC3 and SLC4 this is in the CERN maintained 'openafs' package (i.e. 'apt-get/yum install openafs').

Debian or Ubuntu

Edit your /var/chroot/bind-mount.conf file to contain the following lines:

/afs                /afs
/etc/openafs   /usr/vice/etc

SLC3 and SLC4

Edit your bind-mount.conf file to contain the following lines:

/afs                /afs
/usr/vice/etc   /usr/vice/etc

Source code

Source code is available in the git repository http://github.com/szamcsi/chroot-envs or via git: git://github.com/szamcsi/chroot-envs.git

Divers

Here one can find a list of tips and tricks to make the whole stuff more convenient to use.
  1. In order to easily recognize your chroot terminal you can set
       export PS1="[`whoami`@slc3-chroot:\w\$]: "
       
    in your .bashrc file on the guest OS.
  2. In order to avoid updatedb parsing all the (re)mounted afs filesystem, add your bined afs path to the PRUNEFS variable of your /etc/updatedb.conf.
  3. It is worth copying the resolv.conf of the host OS, for example (from the host OS):
       sudo cp /etc/resolv.conf /var/chroot/slc4/etc/
       


Last edit: UnknownUser on 2010-01-22 - 10:18

Number of topics: 1

Maintainer: AkosFrohner


Edit | Attach | Watch | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r18 - 2010-01-22 - unknown
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    EGEE All webs login

This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Ask a support question or Send feedback