From 622edf8584b5d11e6e54c5c11c64803136535ebe Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 6 May 2021 00:58:39 +0200 Subject: [PATCH] Add arch version for chroot --- home/.local/bin/arch-chroot | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 home/.local/bin/arch-chroot diff --git a/home/.local/bin/arch-chroot b/home/.local/bin/arch-chroot new file mode 100755 index 0000000..77accbf --- /dev/null +++ b/home/.local/bin/arch-chroot @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ "$EUID" -ne 0 ]; then + echo "Must be ran as root" + exit +fi + +# Make sure the partition is mounted according to fstab +mount /mnt/arch + +# Mount necessary directories for chroot to be possible +mount --types proc /proc /mnt/arch/proc +mount --rbind /sys /mnt/arch/sys +mount --make-rslave /mnt/arch/sys +mount --rbind /dev /mnt/arch/dev +mount --make-rslave /mnt/arch/dev + +# Chroot with bash shell +chroot /mnt/arch /bin/bash + +# Unmount recursively mounted directories +umount -l /mnt/arch/dev{/shm,/pts,} +umount -R /mnt/arch + +# Remount partition accordingly to fstab +# (the above umountings will unmount gentoo completely, +# which means that remounting is necessary) +mount /mnt/arch