Run the following commands on linux (4.4.59 and 4.9.8 are tested) and it will fail:
mkdir -p /tmp/proc
mount -t overlay overlay -o lowerdir=/proc:/tmp/proc /tmp/proc
and there is a error message in dmesg
:
overlayfs: maximum fs stacking depth exceeded
Why can't /proc
be a layer of a overlay file system?
If I replace /proc
with /dev
or /sys
, it mounts without issue, so it seems there is something special with /proc
.
P.S. The use case is creating a safer chroot
environment, I want to make /dev
, /sys
and /proc
read-only in chroot
. There are 2 known workarounds:
- read-only bind mount. The limitation is two commnads instead one required.
- read-only special mount:
mount -t proc -o ro none /tmp/proc
. The limitation is sub-mount not mapped automatically.
Anyway, I'm still curious about why /dev
and /sys
play well with overlay but /proc
doesn't.
The question is migrated from stackoverflow.