Skip to content

Instantly share code, notes, and snippets.

@gekola
Created May 20, 2023 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gekola/7bd15bfd80f94a257a76093f218cbb43 to your computer and use it in GitHub Desktop.
Save gekola/7bd15bfd80f94a257a76093f218cbb43 to your computer and use it in GitHub Desktop.
A useful script for working with Gentoo in chroot environment.
#!/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