My script creates a chroot cage to install GRUB to a USB, run as sudo of course:
SYSTEM_DIRS=(etc bin sbin var lib lib64 usr proc sys dev tmp)
boot_partition=/media/user/boot
for dir in ${SYSTEM_DIRS[@]}; do
mount --bind /$dir ${boot_partition}/${dir}
done
Then execute some commands inside the the chroot:
chroot ${boot_partition}/ touch foo # works fine
...
But when I want to execute the command exit
chroot ${boot_partition}/ exit
I get:
chroot: failed to execute the command <<exit>>: No such file or directory
Why does this happen and there is a way to fix it?