SchrootNG

From Etp
Jump to: navigation, search

NOTE: Schroot is being deprecated in favour of Singularity, please have a look at this wiki page

Setup and Configuration

This page describes how to setup and use the schrootNG scripts developed by Felix. They allow the usage of schroot to run in an slc6 environment without having to explicitly setup schroot itself.

Make sure everything is set up by adding this line to '.bashrc':

source /software/opt/trusty/x86_64/schrootNG/20140819/setup.sh

If you want to change the default configuration of schrootNG, copy the config file into your home directory:

cp /software/opt/trusty/x86_64/schrootNG/20140819/etc/schrootNG.conf .schrootNG.conf

There are a couple of options you can set here, which should be fairly clearly described in the comments. Just to point out two interesting ones:

FORCE_EXECUTE_IN_SCHROOT: Defines commands which are automatically executed (i.e. do not need ngsexec, see below)
                           in the schrootNG environment, which is currently set up.
ENVIRONEMT_INI_SCHRIPTS: Scripts, which are executed upon initialisation of the schrootNG environment.

An example for the latter can be found here:

/project/etp/ThomasMaier/public/SchrootNG/.ini_schroot.sh

You can create a new schrootNG environment with

ngs_create.py <name> slc6

which you set up by

ngs_set <name>

and release by

ngs_unset

If you want to remove an environment just type

ngs_rm <name>

or list all environments type

ngs_ls

To send commands to the schroot environment just prepend it with ngsexec, e.g.

ngsexec echo 'bla'

One major advantage is that you can use cvmfs in multiple schroot environments simultaneously (which causes some problems when doing so by setting up schroot directly in multiple shells). Also, all further setups within the schroot environment are saved, which saves you from having to set up everything again when opening a new shell (or executing ngs_set <name> again).

Adding the following to your '.bashrc' adds a tag to your prompt which shows the schroot environment which is currently set (which is very handy for clarity):

case "$TERM" in
xterm)
PS1='\[\033]0;${debian_chroot:+($debian_chroot)}${NG_SCHROOT_SESSION:+($NG_SCHROOT_SESSION)}\u@\h:\w\007\]\[\e[1;39m\]${debian_chroot:+($debian_chroot)}${AtlasVersion:+[$AtlasVersion,$AtlasProject]}${NG_SCHROOT_SESSION:+($NG_SCHROOT_SESSION)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]>'
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w> '
    ;;
esac


Troubleshooting

It can happen that you get this error when trying to remove an existing schrootNG environment:

...Device or resource busy...

Basically that means that some process(es) are still running which access the folder which is created for the schrootNG environment. Go to the .schroot_ng_test folder in your home directory:

cd ~/.schroot_ng_test

There you should see a folder with the name of the schrootNG environment you deleted. If you try to remove it you should get the same error message. Check which processes are still running, which access the folder, and kill them:

lsof +D [MySschrootNGEnv]
kill [StillRunningPID]

You should be able to remove the directory now.