From cb8c7537c0571ba57f4b75498cd63101b7e2148a Mon Sep 17 00:00:00 2001 From: Salt Date: Fri, 4 Dec 2020 02:40:56 -0600 Subject: [PATCH] Dynamically manage mounts in chroot --- gentoostrap.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gentoostrap.sh b/gentoostrap.sh index 84ddee8..47fe4df 100755 --- a/gentoostrap.sh +++ b/gentoostrap.sh @@ -195,11 +195,15 @@ build-gentoo() { popd log "Pivoting to container for more setup" cp "$0" "$_optdest/gentoostrap.sh" - mount --types proc /proc "$_optdest/proc" - mount --rbind /sys "$_optdest/sys" - mount --make-rslave "$_optdest/sys" - mount --rbind /dev "$_optdest/dev" - mount --make-rslave "$_optdest/dev" + if ! grep -qs "$_optdest/proc " /proc/mounts; then + mount --types proc /proc "$_optdest/proc" + fi + for dir in sys dev; do + if ! grep -qs "$_optdest/$mount " /proc/mounts; then + mount --rbind /$mount "$_optdest/$mount" + mount --make-rslave "$_optdest/$mount" + fi + done chroot "$_optdest" /gentoostrap.sh -c chroot "$_optdest" /gentoostrap.sh -d log "Configuration complete! You should be good to reboot now."