Schroot allows users to execute commands or interactive shells in different chroots (see schroot).

Unless otherwise stated, all commands presented on this page must be executed as root.

So, either run them as sudo <command>, or switch to root at the beginning by typing su.

Installation

apt-get install schroot

debootstrap is used to install a Debian base system(the new root), for the example below.

apt-get install debootstrap

Setup

Example

A simple example that creates a chroot and installs <some-package> for an X windows environment. This is not the safest nor a standard way of setup.

Backup:

cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.old

Create root file system:

mkdir -p /srv/chroot/test
debootstrap wheezy /srv/chroot/test

Replace the contents of /etc/schroot/schroot.conf with the following:

# schroot chroot definitions.
# See schroot.conf(5) for complete documentation of the file format.
#
# Please take note that you should not add untrusted users to
# root-groups, because they will essentially have full root access
# to your system.  They will only have root access inside the chroot,
# but that's enough to cause malicious damage.
#
# The following lines are examples only.  Uncomment and alter them to
# customise schroot for your needs, or create a new entry from scratch.
#
#
[wheezy-test]
description=Contains the SPICE program
aliases=test
type=directory
directory=/srv/chroot/test
users=jsmith
root-groups=root
profile=desktop
personality=linux
preserve-environment=true

Where jsmith is an underprivileged user.

schroot -c test

W: Failed to change to directory '/ ... is ok.

apt-get update && apt-get install <some-package>
exit

As the user jsmith execute:

xhost +
schroot -ctest

From this point the <some-package> could be used...

Or,

xhost +
SESH=$(schroot -ctest -b)
schroot -r -c $SESH
schroot -e -c $SESH


See Also :