2

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?

  • A related, but not identical, question is unix.stackexchange.com/questions/22777 – JdeBP Dec 19 '16 at 16:35
  • The related question is exactly what is happening to me. However I don't see a valid explanation as to why this is happening, just ways to avoid it. – jacksonecac Dec 19 '16 at 16:39
3

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.

2

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.

  • Good answer.. can you go into more detail about why or how it shadows? – jacksonecac Dec 19 '16 at 16:50
  • I don't know these. The "why" part must've been decades ago, if there's some longer story to it. "How"/implementation might be different on each UNIX-like system, but I'm just guessing... – Vladimír Čunát Dec 19 '16 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.