Build a Debian chroot environment

You can easily create a base Debian system using debootstrap. To have a usable chroot environment, you'll also need to mount both the dev and proc filesystems. Follow these steps for more details.

  1. Create a directory that you want to use for the base system (chroot-debian in this case).
    mkdir chroot-debian
  2. Create a base system using debootstrap
    sudo debootstrap sid chroot-debian http://mirror.pacific.net.au/debian/

    You can change sid to stable to use the stable distribution, and to use Debian mirror closer to your physical location for faster download speed.

  3. Mount proc and dev filesystem
    sudo mount -o bind /dev chroot-debian/dev
    sudo mount -o bind /proc chroot-debian/proc
  4. Start chrooting
    sudo chroot chroot-debian /bin/bash
  5. Once done, exit the session and don't forget to unmount the dev and proc filesystem
    sudo umount chroot-debian/dev chroot-debian/proc

Sign up for Learn Linux in 5 Days and Level Up Your Career and many other great courses on Udemy to learn more.


Written by Mohd Shakir Zakaria. Last updated on 2019-02-12