Does schroot allow configuration files in the home directory to be overwritten?

Solution 1:

When /home is mounted by schroot, all configuration files are placed in $HOME of the base install, irrespective of whether they belong to the schroot.

This can lead to configuration files being overwritten when two versions of a package are installed, one in the base install and the other in the schroot.

It's easy to alter the schroot setup so that its configuration files are placed in a different directory, as shown in the following example.

A schroot for wheezy-amd64 is located in /var/schroot/wheezy-amd64. This particular schroot is using the 'desktop' profile, hence its mount points are defined in /etc/schroot/desktop/fstab.

First, create a home directory for the user inside the schroot,

mkdir /var/schroot/wheezy-amd64/home/$USERNAME

Second, replace the following line in /etc/schroot/desktop/fstab,

/home          /home           none    rw,bind         0       0

with,

/home          /HOME           none    rw,bind         0       0

That's all! It's also convenient to add an alias to ~/.bash_aliases in the base install,

alias wheezy64='schroot -c wheezy-amd64 `/bin/echo "-d $PWD" | /bin/grep "^-d[ ]*\/home" | sed "s/home/HOME/"`'

Inside the schroot, the user now sees two home directories:

  • /home/$USERNAME is the schroot home directory.
  • /HOME/$USERNAME is the home directory of the base install.