# The Devpts Filesystem

_Peios Kernel / Internals / Filesystems_

> Each mount of the devpts filesystem is now distinct such that ptys and their indices allocated in one mount are independent from ptys and their indices in all other mounts.

> **Peios:** Unix mode, ownership and ACL examples describe the inherited metadata model. On managed Peios mounts, native security descriptors and granted handle rights determine access; `chmod`, `chown` and POSIX ACL recipes alone do not delegate it. Mount operations also require native authorization. See [Peios kernel behaviour](</kernel/introduction/peios-behaviour.md>) for mount-policy defaults and the tmpfs rootfs rule.


<a id="rst-the-devpts-filesystem"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

Each mount of the devpts filesystem is now distinct such that ptys and their indices allocated in one mount are independent from ptys and their indices in all other mounts.

A devpts instance creates its `ptmx` node with default mode `0000`; the `ptmxmode` mount option can select a different mode. These are Unix metadata values, not a native Peios access grant.

To retain backwards compatibility a ptmx device node (aka any node created with `mknod name c 5 2`) when opened will look for an instance of devpts under the name `pts` in the same directory as the ptmx device node.

Instead of a separate `/dev/ptmx` device node, `/dev/ptmx` can be a symlink or bind mount to `/dev/pts/ptmx`. The conventional Unix setup uses `ptmxmode=0666` or changes that node's mode after mounting. In Peios, mode changes alone do not authorize access: the mount and native descriptor policy must also permit the caller's operations. Do not use `chmod 0666` as evidence that PTY access has been delegated.

Total count of pty pairs in all instances is limited by sysctls:



```text
kernel.pty.max = 4096       - global limit
kernel.pty.reserve = 1024   - reserved for filesystems mounted from the initial mount namespace
kernel.pty.nr               - current count of ptys
```

Per-instance limit could be set by adding mount option `max=<count>`.

This feature was added in kernel 3.4 together with `sysctl kernel.pty.reserve`.

In kernels older than 3.4 sysctl `kernel.pty.max` works as per-instance limit.
