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.
apt-get install schroot
debootstrap is used to install a Debian base system(the new root), for the example below.
apt-get install debootstrap
Configuration file: /etc/schroot/schroot.conf
If you prefer separate configuration files, place them in /etc/schroot/chroot.d/.
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.
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 script-config=desktop/config 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...
xhost + SESH=$(schroot -ctest -b) schroot -r -c $SESH schroot -e -c $SESH
See Also :
Kde4schroot - How-to set up a schroot to run KDE4
http://linuxgazette.net/150/kapil.html - Virtualizing without Virtualizing
other SystemVirtualization solutions