Hi everybody,
I was toying with overlayfs and mount namespaces. I was trying to mount one filesystem with it's /usr, /var, etc over the rootfs. The idea is to have several applications or versions of the same application as filesystems, and mount one or another. Let's say a kind of package manager. Nothing new, I think.
So I created a tmpfs with three dirs (upper, work, lower), a new mount namespace, and mounted them over the rootfs:
Quote:
# New mountspace
unshare -m
# Work in a differente fs.
mkdir /tmp/testfs
mount -t tmpfs tmpfs /tmp/testfs
cd /tmp/testfs
# /tmp/testfs/{lower|upper|work}
export LOWER=lower
export UPPER=upper
export WORK=work
mkdir $LOWER $UPPER $WORK
mount -t overlay -olowerdir=$LOWER,upperdir=$UPPER,workdir=$WORK overlayfs /
|
This should make a mess, because the rootfs would be empty. But it doesn't. ls -l / shows the whole filesystem. And if I create a new file in / (inside that namespace), it appears also outside that namespace.
What am I doing wrong? Maybe it's just not possible, but I would love to know why.
TIA,