You are not logged in.

#1 2011-07-26 14:05:56

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

[SOLVED] How to chown files in mounted drive?

I'm trying to mount my 2nd hard drive (used as a data partition by a prior Win7 installation) as user.

In /etc/fstab I have:

/dev/sdb5   /mnt/win     auto    user,noauto    1    1

I can then run "mount /dev/sdb5" without sudo. But it sets the owner and group of /mnt/win to root:root and permissions to -rwx------

Running "sudo chown -R ian:users /mnt/win" only changes the directories, not the files. I can't find anything in the chown manpage to indicate an option I'm missing. Can anybody help me out? Not much point mounting the partition if I can't even read them.

Thanks.

Last edited by ibrunton (2011-07-26 14:33:56)

Offline

#2 2011-07-26 14:07:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to chown files in mounted drive?

You can mount it with other options - 'man mount'. (e.g. dmask=007,fmask=117)

Last edited by karol (2011-07-26 14:15:06)

Offline

#3 2011-07-26 14:20:40

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [SOLVED] How to chown files in mounted drive?

There's nothing in 'man mount' about dmask or fmask...

Offline

#4 2011-07-26 14:24:30

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to chown files in mounted drive?

ibrunton wrote:

There's nothing in 'man mount' about dmask or fmask...

Hmmm

[karol@black ~]$ man mount | grep -A2 "dmask=value"
       dmask=value
              Set the umask applied to directories only.  The default is the umask of the  cur‐
              rent process.  The value is given in octal.
[karol@black ~]$ man mount | grep -A2 "fmask=value"
       fmask=value
              Set  the  umask  applied  to regular files only.  The default is the umask of the
              current process.  The value is given in octal.

I use

mount -o gid=users,uid=1000,dmask=0002,fmask=0113 /dev/sdb1 /media/usb/

and get

[karol@black ~]$ ls -l /media/
total 12
drwxr-xr-x  2 root  root  4096 2011-01-10  cd
drwxrwxr-x 13 karol users 8192 1970-01-01  usb

You can find your uid (your user id) in /etc/passwd and your gid (group - i.e. 'users' -  id) - in /etc/group.

Last edited by karol (2011-07-26 14:28:23)

Offline

#5 2011-07-26 14:33:40

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [SOLVED] How to chown files in mounted drive?

karol wrote:
ibrunton wrote:

There's nothing in 'man mount' about dmask or fmask...

Hmmm

[karol@black ~]$ man mount | grep -A2 "dmask=value"
       dmask=value
              Set the umask applied to directories only.  The default is the umask of the  cur‐
              rent process.  The value is given in octal.
[karol@black ~]$ man mount | grep -A2 "fmask=value"
       fmask=value
              Set  the  umask  applied  to regular files only.  The default is the umask of the
              current process.  The value is given in octal.

Now, that worked. When I tried searching from within man, it said the pattern (fmask) was not found. I guess I'm just not good enough at commands in man yet.

karol wrote:

I use

mount -o gid=users,uid=1000,dmask=0002,fmask=0113 /dev/sdb1 /media/usb/

That also worked. Thanks!

Offline

Board footer

Powered by FluxBB