Skip to content

Instantly share code, notes, and snippets.

@m87h
Created June 28, 2013 17:18
Show Gist options
  • Save m87h/5886395 to your computer and use it in GitHub Desktop.
Save m87h/5886395 to your computer and use it in GitHub Desktop.
#!/bin/bash
MOUNTS=(/proc /sys /dev /dev/pts)
if [ -n "$1" ]; then
for f in "${MOUNTS[@]}"; do
mount --bind $f "$1$f"
done
fi
chroot "$@" || exit $?
if [ -n "$1" ]; then
for ((i=${#MOUNTS[@]}-1; i>=0; i--)); do
umount "$1${MOUNTS[$i]}"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment