Here is a bash script I wrote to enter and exit a chrooted environment on my Gentoo.
#!/bin/bash # define here the chroot jail path CHROOT=/home/chroot-jail start() { echo "Mounting chroot dirs" # This allows DNS lookups via your system's networking cp -L /etc/resolv.conf ${CHROOT}/etc/ mount -o bind /proc ${CHROOT}/proc mount -o bind /proc/bus/usb ${CHROOT}/proc/bus/usb mount -o bind /dev ${CHROOT}/dev mount -o bind /dev/pts ${CHROOT}/dev/pts mount -o bind /dev/shm ${CHROOT}/dev/shm mount -o bind /sys ${CHROOT}/sys chroot ${CHROOT} /bin/bash } stop() { echo "Unmounting chroot dirs" umount -f ${CHROOT}/proc/bus/usb >/dev/null umount -f ${CHROOT}/proc >/dev/null & umount -f ${CHROOT}/dev/pts >/dev/null umount -f ${CHROOT}/dev/shm >/dev/null umount -f ${CHROOT}/dev >/dev/null & umount -f ${CHROOT}/sys >/dev/null & } usage() { echo "$0 [start|stop]" } if [ "$1" == "start" ] then start elif [ "$1" == "stop" ] then stop else usage fi
You can find more information on setting up a chroot at the:
0