Get started with Debian chroot

Create a Debian chroot

$ sudo debootstrap <code name> <chroot folder> <apt repo URL>

# Example
$ sudo debootstrap buster ./chroot-buster http://deb.debian.org/debian

Mount neccessary folders for work

$ sudo mount -t devtmpfs none chroot-buster/dev
$ sudo mount -t devpts none chroot-buster/dev/pts
$ sudo mount -t tmpfs none chroot-buster/dev/shm
$ sudo mount -t proc none chroot-buster/proc
$ sudo mount -t sysfs none chroot-buster/sys

Jump into chroot

$ sudo chroot chroot-buster

Tip: By default, you will login as root. If you want to login to a user (ex: steve) in chroot

$ sudo -S chroot chroot-buster /bin/bash -c "cd /home/steve; su steve"

See also

comments powered by Disqus