Actually, there is a better workaround, that I found it schroot FAQ, in section Why is schroot overwriting configuration files in the chroot?
By default, schroot copies over the system NSS databases ('passwd', 'shadow', 'group', 'gshadow', 'services', 'protocols', 'networks', and 'hosts', etc.) into the chroot. The reason for this is that the chroot environment is not a completely separate system, and it copying them over keeps them synchronised. However, this is not always desirable, particularly if installing a package in the chroot creates system users and groups which are not present on the host, since these will disappear next time the databases are copied over.
In short: each time you start a new schroot session, or after host system reboot, schroot grabs /etc/passwd
and some other files from you real system and copies them into chroot, thus losing all new users from it. The suggested workaround is described in this FAQ: you can disable copying this files:
- Open
/etc/schroot/default/nssdatabases
(on your real system, of course) - You will see the lis of so called NSS databases, that are copied from real system.
- Comment lines
passwd
, group
and shadow
, so that the file looks like this:
/etc/schroot/default/nssdatabases
# System databases to copy into the chroot from the host system. # # <database name> #passwd #shadow #group services protocols networks hosts
Now if you go back inside your chroot and create some users, or install some postgresql etc, new users won't be lost. Even after reboot!