Debian Notes

Reference material

  1. Debian chroot wiki

How I set up a chroot

For hacking on Debian I needed a sid chroot. I created this with the Ubuntu version of debootstrap, which might not be recommended but worked well enough for me at the time.

# Create the chroot environment
sudo apt-get install debootstrap
sudo mkdir -p /chroot/sid
sudo debootstrap sid /chroot/sid http://deb.debian.org/debian

# Bind-mount required things (once per reboot)
export CHRDIR=/chroot/sid
sudo mount --bind /dev ${CHRDIR}/dev
sudo mount --bind /dev/pts ${CHRDIR}/dev/pts
sudo mount --bind /proc ${CHRDIR}/proc

# Entering the chroot
sudo chroot /chroot/sid /bin/bash

# Setup in chroot
# - add a user
adduser $NewUser
# - add user to sudo group
usermod -aG sudo $NewUser

# login as my user account in the chroot
sudo -u $NewUser bash -l

# any user setup

Using the chroot:

# Bind-mount required things (once per reboot)
export CHRDIR=/chroot/sid
sudo mount --bind /dev ${CHRDIR}/dev
sudo mount --bind /dev/pts ${CHRDIR}/dev/pts
sudo mount --bind /proc ${CHRDIR}/proc

# Use the chroot, switch to user-account
sudo chroot /chroot/sid /bin/bash
sudo -u $NewUser bash -l
cd