1

I have a question about mount in Linux Fedora. I have a mount point inside my home directory. The mount point is at /home/user/project and in fstab I have added the line:

/dev/mapper/fedora-proj /home/user/project ext4 defaults 1 2

The directory /home/user/project has the file permissions 0755 and it is owned by user. But when I do 'mount -a', the directory owner gets changed to root and the permissions are 777. I know ext2/3/4 do not have uid= and gid= options, but why is the mounting point receives hard coded file permissions during mount and how can I change it?

P.S

The test was made on Fedora 25. When I am doing the exact same procedure on Fedora 23 I see a different behavior: the mount directory permissions are changing to 755 (before mount it is 0777)

1 Answer 1

6

The permissions for the root of a mountpoint are stored on the mounted filesystem (it actually makes sense this way; otherwise, where would the permissions for the root directory / be stored?). You change them the normal way: chmod, chown, etc.

Before mounting, you're seeing the permissions for the mountpoint directory on the parent filesystem. After mounting, you're seeing the permissions for the root of the mounted filesystem.

Example: You have two filesystems:

FS-A             FS-B
/                /
  /mnt             /file1
    /foo           /file2
  /etc           
⋮

Note both of them have a topmost/root directory (/), as all (Unix) filesystems do. FS-A has has two subdirectories shown (/mnt and /etc) and /mnt has a subdirectory /mnt/foo. FS-B has two files, /file1 and /file2. Being Unix filesystems, all of these directories and files have a user, a group, and permissions. Now, let's make FS-A the root filesystem, and mount FS-B at /mnt/foo. We then get:

/                   # FS-A /
  /mnt              # FS-A /mnt
    /foo            # FS-A /mnt/foo *or* FS-B /
      /file1        # FS-B /file1
      /file2        # FS-B /file2
  /etc              # FS-A /etc
⋮

Note how we have a choice of what /mnt/foo is—it could be /mnt/foo from FS-A or / from FS-B. Both have exactly the same path. Unix's designers chose FS-B.

PS: your fstab line is missing the filesystem type. Should come before the options (defaults).

3
  • I did not understand. Why are the permissions of the folder on the parent filesystem are also changed?? Commented May 25, 2017 at 6:11
  • @ErectCrested they're not changed, that folder is hidden. It's hidden by the mounted filesystem taking over that folder. You see the permissions of the root of the mounted fs instead of the permissions of that folder. Will edit to try and clarify.
    – derobert
    Commented May 25, 2017 at 15:12
  • @ErectCrested I added an example that I hope explains better. Does that help?
    – derobert
    Commented May 25, 2017 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .