Created
May 20, 2023 11:57
-
-
Save gekola/7bd15bfd80f94a257a76093f218cbb43 to your computer and use it in GitHub Desktop.
A useful script for working with Gentoo in chroot environment.
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/bash | |
set -e -o pipefail | |
BASEDIR=$(dirname "$(readlink -f $0)") | |
if ! grep -q "${BASEDIR}/proc" /proc/mounts; then | |
mount --types proc /proc "${BASEDIR}/proc" | |
fi | |
if ! grep -q "${BASEDIR}/sys" /proc/mounts; then | |
mount --rbind /sys "${BASEDIR}/sys" | |
mount --make-rslave "${BASEDIR}/sys" | |
fi | |
if ! grep -q "${BASEDIR}/dev" /proc/mounts; then | |
mount --rbind /dev "${BASEDIR}/dev" | |
mount --make-rslave "${BASEDIR}/dev" | |
fi | |
exec chroot "${BASEDIR}" /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment