For virtualization technologies (e.g., environments, machines) Linux now supports containers which allow multiple instances of the devpts filesystem. This allows the /dev/pts instance indices in one virtual environment to be independent of the indices allocated in another environment.
As detailed in the kernel file Documentation/filesystems/devpts.txt, this requires the kernel option:
and the "-o newinstance" mount option when mounting devpts.
Gentoo's sys-apps/openrc-0.8.3-r1 configuration has a /dev/init.d/devfs script in the sysinit runlevel. Despite it name and the fact that the system uses udev, the devfs initscript states that it mounts "required stuff as user may not have [them] in /etc/fstab". Unfortunately, the devfs script does not check for entries in fstab before mounting the devpts and shm filesystems. Fortunately, the Documentation/filesystem/devpts.txt nicely mentions what to do if initscripts are not updated to handle CONFIG_DEVPTS_MULTIPLE_INSTANCES. Since one doesn't likely want to do such things manually after every reboot and it is generally a bad idea to start editing a distribution's installation scripts, here's an initscript that performs the devpts.txt file's instructions:
description="Multiple PTY fix for /dev/ptmx"
depend()
{
after udev devfs
}
start()
{
if [ -e /dev/pts/ptmx ]; then
# Use next line if devpts is in /etc/fstab...
mount -o remount /dev/pts
# Or uncomment next line...
#chmod 0666 /dev/pts/ptmx
rm /dev/ptmx
ln -s pts/ptmx /dev/ptmx
return 0
else
echo "/dev/ptmx does not exist!"
return 1
fi
}
which also requires this line to be in /etc/fstab (but adjust the perms to your liking):
and to run in the sysinit runlevel:
Test it by rebooting and checking that /dev/ptmx is a symlink to /dev/pts/ptmx and the permissions of /dev/pts/ptmx are 0666. 🙂
Many thanks, man! It allowed me to run
in Debian lxc container under under non-root user account.
In fact
fstab line alone was enough.