4

I cannot create files in my newly mounted partition . The folder to which i am mount the partition, /media/hrmount, is owned by root so even if I add a fstab line like

UUID=irrelevant /media/hrmount  ext4   defaults,user      0      2

/media/hrmount is still owned by root when i remount "irrelevant" .

And if i delete the directory in hope that "mount" will create it automatically and make it owned the user that issued the mount command I'll just get an error message saying the directory does not exist.

I could just use chown to make the directory owned by uid1000 but I understand it should not be needed plu I am positive that if i create another user, let's call him uid1001, then if we unmount the partition fs and then remount it as uid1001 it's mount point, /media/hrmount will still be owned by uid1000. This means I'll have to fiddle with permissions and while I can do that I have heard that just by adding the device to fstab like above should just work. How can I achieve that?

The ideal behaviour would be to just issue the mount device command either by sudoing or normally and the partition is mounted and also the folder is automatically created.

PS: I'm on Linux Mint 13

7

If a Linux filesystem (not e.g. FAT32, NTFS) is mounted then the directory permissions for the root directory are taken from the filesystem.

root must either change the owner (chown) or permissions (chmod, setfacl) of the root directory or has to create subdirectories which are writable by the users. The latter is what happens with the normal root volume: With the exception of tmp no standard directory is writable by users. The users can write to their directory below /home (and maybe to non-standard directories and subdirectories).

4

After the mounting the uid:gid and permissions of the mount point are set to ones from the root directory of the mounted partition. So to change the owner/permissions mount the partition as root, chdir to the mount point and set them as you want using

# chmod 777 .

or

# chown johndoe:users .

  • Welcome to unix.SE. This will need to be done when unmounted, right? – Tom Hale Feb 26 '17 at 12:49
2

You are confusing the generic option user with the filesystem specific option uid.

from fstab(5)

user allow a user to mount

and from mount(8)

uid=value and gid=value Set the owner and group of all files. (Default: the uid and gid of the current process.)

which applies to the msdos, umsdos and vfat filesystems. you can do similar options with adfs, affs, devpts, hfs, hpfs, iso9660, ntfs, tmpfs, udf and usbfs filesystems. you do not need to set the uid on any filesystem that was designed for unix, Indeed you do not want to, as the filesystem can do this itself.

  • uid=1000 or some other number does not work in fstab for non ntfs files from what i can see – bloys Jan 27 '15 at 13:52
  • Setting the uid ONLY WORKS on the filesystems listed. It does not work with any ext filesystem. It does not work on jfs, xfs, or any filesystem designed for UNIX or Linux. There would be advantages to extending the uid option to all filesystems (expecialy for removable media used on multiple computers) but that is not the case. but my main point was that the user option (which works fine) not only does not do what you want, it does something you probably do not want. – hildred Jan 27 '15 at 14:17
0

Thank you all for the provide information. I have managed to mount the partition's filesystem as I wanted. The correct way to achieve what I wanted was to edit /etc/fstab ( i gave up using the user/users option ) then do a sudo mount -a and it worked great. When I dismount irrelevant, /media/hrmount becomes owned by root:root . After I do a sudo mount -a the mount point switches the owner to uid1000:uid1000 .

  • 4
    You say that you edited /etc/fstab — what did you put in it?  Your question shows that your /etc/fstab entry says ext4 — are you sure that the filesystem is really an ext4 filesystem?  Did you chown the filesystem to 1000:1000? – G-Man Jun 23 '15 at 11: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.