8

I'm mounting a filesystem as root and I don't understand why it is not owned by root but by an unprivileged user.

Here's fstab:

cat /etc/fstab
[...]
/dev/sdb        /mnt/projects ext4 defaults 0 2

And here's what happens when mounting:

ls -al /mnt/projects/ 
total 8
drwxr-xr-x 2 root root 4096 mai   25 17:55 .
drwxr-xr-x 3 root root 4096 mai   25 17:55 ..

mount /dev/sdb

ls -al /mnt/projects/ 
total 24
drwx------ 3 jerome jerome  4096 mai   25 17:52 .
drwxr-xr-x 3 root   root    4096 mai   25 17:55 ..
drwx------ 2 root   root   16384 mai   25 17:52 lost+found

I'm not using sudo. I switch to root user with the su command.

The user that gains ownership is my normal user, the first declared when installing the system (uid: 1000).

The mount point is owned by root. I don't think that matters anyway.

My normal user doesn't have the permissions to mount the filesystem here himself.

22

This means that the file system being mounted contains a root directory owned by user 1000 and group 1000. The ownership of a mounted file system’s root directory becomes the ownership of the mount point.

  • 1
    I suppose this is because I created the partition using gnome-disks as unprivileged user. But there is nothing in that GUI informing me about it. – Jérôme May 28 '18 at 8:22
  • 3
    @Jérôme The owner of the root of a file system can be changed with chown just like any other directory. – kasperd May 28 '18 at 10:21
  • OK @kasperd. I was just surprised it was jerome and not root in the first place since I thought I did everything as root. – Jérôme May 28 '18 at 10:29

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.