How to set the owner of a mounted partition in Linux?

13

2

I have two mechanical HDD's in my computer.I run Windows on disk 0 and Crunchbang on disk 1. I always have to use elevated privileges in Crunchbang in order to copy files to the NTFS partition in disk 0.

enter image description here

As far as i know, the commands like chmod and chown , which are used for setting file permissions , only hold for file system objects. Also i know that , "In Linux everything is a file". i.e, there are special files that represent hardware devices , system information etc.. Since these special files belong to the virtual file system /dev they should be file system objects and so the commands like chown ,chmod should work on these files. I have successfully changed the owner and write permissions of the device sda by the command

chown aswin sda

where as i can neither change the owner / permissions of the mounted partition. I have tried to set the local user as the owner of the mounted partition and set permissions to read,write,execute.But , still the problem persists.

enter image description here

Am i missing something ?How to set the permission on this disk so that i can write into it without elevated privileges ?

Ashildr

Posted 2013-10-12T16:25:21.803

Reputation: 2 574

1

You probably mounted it using /etc/fstab. Check this: http://superuser.com/questions/320415/linux-mount-device-with-specific-user-rights

– Savvas Radevic – 2013-10-12T16:43:21.940

Did you install ntfs-3g? – MariusMatutiae – 2013-10-12T16:44:29.777

@MariusMatutiae ntfs-3g is already the newest version. – Ashildr – 2013-10-12T16:48:09.947

Answers

7

You should NOT touch /dev/sd* permissions (I'm not talking about /media/sda4). If you did change them, please undo your changes and use the default permissions, because it can interfere with other programs. (I think the default owner/group are root:disk)

You have to unmount the disk first in order to change the permissions of the mount folder /media/Disk.

umount /media/Disk
chown aswin:aswin /media/Disk
mount -va

In order to mount the disk contents with a specific user/group id, you can set a specific uid/gid (User ID and Group ID) within /etc/fstab. See Linux - Mount device with specific user rights

Also, you have other solutions other than fstab, meaning GUI-based gnome environment:

gvfs-mount -d /dev/sdXY

...where it mounts the sdXY (change "X" and "Y" with the appropriate letter&number) partition and sets the user as the owner. Gnome environment also allows to click on a partition on the left side menu of nautilus (the file manager) and it auto-mounts the partition.

Savvas Radevic

Posted 2013-10-12T16:25:21.803

Reputation: 1 056

1+1 for gvfs-mount ! With mount alone, I didn't managed to allow a standard user to "own" the mount (i.e. allow non-root to unmount) without editing fstab or mtab. – KrisWebDev – 2016-03-20T18:54:48.147

Can this answer be updated for gio? On Ubuntu 19.04, run: $ gvfs-mount, get:

See 'gio help mount' for more info.```
 – BobHy  – 2019-07-28T17:21:58.127