2

I want to create multiple chroot environments, but I faced the issue with mounting devpts

Here is STR:

> mkdir -p {1,2}/{proc,sys,dev/pts}
> mount -v -t sysfs   sysfs    1/sys/
> mount -v -t proc    proc     1/proc/
> mount -v -o bind    /dev     1/dev/
> mount -v -o bind    /dev/pts 1/dev/pts

> mount -v -t sysfs   sysfs    2/sys/
> mount -v -t proc    proc     2/proc/
> mount -v -o bind    /dev     2/dev/

> mount | grep "/root/"  | awk '{print $3}' | sort
/root/1/dev
/root/1/dev/pts
/root/1/proc
/root/1/sys
/root/2/dev
/root/2/proc
/root/2/sys

If I mount '/dev/pts' to the '2/dev/pts' directory, I will get duplicate mount points

> mount -v -o bind    /dev/pts 2/dev/pts
mount: /dev/pts bound on /root/2/dev/pts.

As you can see after these actions system creates two mount points for '/root/1/dev/pts':

> mount | grep "/root/"  | awk '{print $3}' | sort
/root/1/dev
/root/1/dev/pts <---
/root/1/dev/pts <---
/root/1/proc
/root/1/sys
/root/2/dev
/root/2/dev/pts <---
/root/2/proc
/root/2/sys

If I unmount the first mount point, the second one will be unmounted too

> umount -v /root/1/dev/pts
umount: /root/1/dev/pts unmounted
> mount | grep "/root/"  | awk '{print $3}' | sort
/root/1/dev
/root/1/dev/pts <---
/root/1/proc
/root/1/sys
/root/2/dev
/root/2/proc
/root/2/sys

Could you please explain to me why it happens?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.