Last active
March 22, 2024 18:13
-
-
Save schtobia/ea1b786d915415f86099 to your computer and use it in GitHub Desktop.
Mount /tmp, /dev/pts, /dev/shm and /proc into chroot and change into chroot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
[ ! -d "$1" ] && echo "$1 is not a valid directory." && exit 1; | |
trap "umount \"${1}\"/tmp \"${1}\"/dev/null \"${1}\"/dev/pts \"${1}\"/dev/random \"${1}\"/dev/shm \"${1}\"/dev/urandom \"${1}\"/proc" EXIT INT TERM HUP PIPE && | |
mount --bind /tmp "${1}/tmp" && \ | |
mount --bind /dev/null "${1}/dev/null" && \ | |
mount --bind /dev/pts "${1}/dev/pts" && \ | |
mount --bind /dev/random "${1}/dev/random" && \ | |
mount --bind /dev/shm "${1}/dev/shm" && \ | |
mount --bind /dev/urandom "${1}/dev/urandom" && \ | |
mount --bind /proc "${1}/proc" && \ | |
chroot "$@"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The shortened URL for this script is https://tms.pw/tschroot .