In the following linked article they explain how to create a "chroot" /tmp directory. I'm a bit confused by what they did. Could someone explain what the following commands are doing?
Noexec and /tmp Troubleshooting
1. # mkdir -p /root/chroot /root/tmp
2. # mount --bind / /root/chroot
3. # mount --bind /root/tmp /root/chroot/tmp
4. # chroot /root/chroot
In the first step, why did they create /root/tmp and not /root/chroot/tmp?
Does the first mount command affects the second one? On the second step they are binding the new directory /root/chroot to the root directory. Does that mean that on the third step /root/tmp actually points to /root/chroot/root/tmp ? Where does /root/chroot/tmp comes from? That's the part I'm getting confused.
What's the logic behind this?