dotfiles/root/usr/local/bin/arch-chroot

29 lines
714 B
Plaintext
Raw Normal View History

2021-05-05 22:58:39 +00:00
#!/bin/sh
if [ "$EUID" -ne 0 ]; then
echo "Must be ran as root"
exit
fi
# Make sure the partition is mounted according to fstab
2021-07-14 12:30:35 +00:00
mount /mnt/arch 2> /dev/null
2021-05-05 22:58:39 +00:00
# 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
2021-07-14 12:30:35 +00:00
# Chroot with zsh shell
chroot /mnt/arch /bin/zsh --login
2021-05-05 22:58:39 +00:00
# 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