I am working with LVM and filesystems and I am confused why when I do a
mkdir /mntpt and then a
mount /mntpt that I am seeing permissions change. It is still a directory is it not?
What is happening under the hood?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
To me, the non obvious part used to be that the root of a file system is a directory as well, just like any other. So you really have two directories at the same location: the original mount point and the root of the mounted file system.
Before the mount, you see the permissions of the mount point. After the mount, you see the permissions of the root of the mounted file system because that's what is now there. It's the same with the content: it goes from the (usually) empty mount point to the content of the root of the mounted file system. When you think about it, it wouldn't make sense if you had the contents of the mounted file system with the permissions of the mount point.
Mounting shadows anything under that directory, including (properties of) the directory itself.
It would feel counter-intuitive to me otherwise, as I naturally consider the root of the mounted hierarchy to be a part of it, so the thing you mount is a (connected) tree.