Making a chroot of a Debian system is very easy when you use debootstrap. In this post, I show how to make a chroot of Debian Buster for a production environment.
First, create a directory to your chroot.
# mkdir -p /debootstrap/dbs-buster
Install debootstrap.
# apt update && apt install debootstrap
Run debootstrap.
# debootstrap buster /debootstrap/dbs-buster http://deb.debian.org/debian/
Set the chroot name by creating the file /debootstrap/dbs-buster/etc/debian_chroot with the name of your chroot.
Now, enter on the chroot environment.
# chroot /debootstrap/dbs-buster
Configure locales and the clock.
# apt install locales
# dpkg-reconfigure locales
i.e. en_US.UTF-8
# dpkg-reconfigure tzdata
i.e. America -> São Paulo
Type Ctrl-D to leave the chroot.
Add entries on /etc/fstab to automount proc/sys/dev fs.
# export CHROOT=/debootstrap/dbs-buster
# echo "proc $CHROOT/proc proc defaults 0 0" >> /etc/fstab
# echo "sysfs $CHROOT/sys sysfs defaults 0 0" >> /etc/fstab
# echo "devpts $CHROOT/dev/pts devpts defaults 0 0" >> /etc/fstab
# mount proc $CHROOT/proc -t proc
# mount sysfs $CHROOT/sys -t sysfs
# mount devpts $CHROOT/dev/pts -t devpts
Final configurations.
# cp /etc/hosts $CHROOT/etc/hosts
# cp /proc/mounts $CHROOT/etc/mtab