LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Can't mount / as an overlayfs (maybe rightfully) (https://www.linuxquestions.org/questions/linux-kernel-70/cant-mount-as-an-overlayfs-maybe-rightfully-4175580283/)

dvadell 05-20-2016 12:38 PM

Can't mount / as an overlayfs (maybe rightfully)
 
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,

sag47 05-21-2016 08:57 PM

Here's Kernel docs on overlayfs https://www.kernel.org/doc/Documenta.../overlayfs.txt

I didn't read anything that specifically mentioned you couldn't overlay on rootfs.


All times are GMT -5. The time now is 08:44 PM.