[SOLVED]chmod/chown does not change permission/ownership

General support questions
Post Reply
taiyebur
Posts: 5
Joined: 2015/11/10 06:45:33

[SOLVED]chmod/chown does not change permission/ownership

Post by taiyebur » 2015/11/12 17:58:49

I have a 2TB hdd. It is mainly a storage hdd. I have recently installed Centos 7. Before that it was Windows. The hdd contained too much data to relocate and format to ext4. Thus, it has ntfs file system. The main problem is all of them has a 777 permission and the secondary problem is their owner and group can't be changed. Even one full drive is owned by root.

This is what it looks like.

Code: Select all

drwxr-xr-x. 2 pial pial   4096 Nov 12 14:58 1
drwxrwxrwx. 1 root root  12288 Nov 10 06:42 2   <-----drive one
drwxrwxrwx. 1 pial users 20480 Nov 10 06:48 3  <-----drive two
drwxr-xr-x. 2 pial pial   4096 Nov 12 15:00 cdrom
drwxr-xr-x. 2 pial pial   4096 Nov 12 14:47 usb

These commands does not work. Not as root either.

Code: Select all

chmod -R 755 /media/2
chmod -R 755 /media/3
chown -R pial:pial /media/2
...........
Here, someone solved it.
http://askubuntu.com/questions/342791/f ... ont-change
http://askubuntu.com/questions/11840/ho ... 1054#91054

I tried this solution but it did not work. This is my /etc/fstab

Code: Select all

#
# /etc/fstab
# Created by anaconda on Thu Nov 12 14:38:48 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       ext4    defaults        1 1
UUID=a83fa641-e851-4dd0-99f2-cc4bb7f811ff /boot                   ext4    defaults        1 2
/dev/mapper/centos-home /home                   ext4    defaults        1 2
/dev/mapper/centos-pandora_l /mnt/data               ext4    defaults        1 2
/dev/mapper/centos-swap swap                    swap    defaults        0 0
UUID=1AD4F0A3D4F081F5   /media/2        ntfs-3g defaults,users,locale=en_US.utf8,exec,permissions,uid=1000,gid=100      0 0
UUID=D83CFF6F3CFF46D2   /media/3        ntfs-3g defaults,users,locale=en_US.utf8,exec,permissions,uid=1000,gid=100       0 0
Here, someone else is saying it cannot be done.
http://unix.stackexchange.com/questions ... filesystem

What is going wrong here? Any solution?


SOLUTION:


NTFS filesystem cannot use linux filesystem permissions like native linux partitions ,e.g. ext4, do. This is why chmod and chown do not work. So, a virtual permission is given to the files. It is done when mounting the partition. So, any and all kind of ownership and file access permission needs to be set when mounting. This is my final version of /etc/fstab that solved my problem.Here,
directory permission = drwxr-xr-x
file permission = -rw-rw-r--

Code: Select all

#/dev/sdb2 on /media/2 on startup
UUID=1AD4F0A3D4F081F5	/media/2	ntfs-3g	defaults,exec,locale=en_US.utf8,permissions,inherit,dmask=022,fmask=113,uid=1000,gid=1000  0 0
#/dev/sdb3 on /media/3 on startup
UUID=D83CFF6F3CFF46D2	/media/3	ntfs-3g	defaults,exec,locale=en_US.utf8,permissions,inherit,dmask=022,fmask=113,uid=1000,gid=1000  0 0
This is the options you need when mounting using "mount" command.

Code: Select all

sudo mount -t ntfs-3g -o uid=1000,gid=1000,dmask=022,fmask=113,utf8,nls=en_US.utf8 /dev/sdb2 /media/2/
dmask and fmask is given in octal. To get the octal version of your desired permission subtract it from 777.
my desired permission for files is 664 . The octal version is 777 - 664 = 113

To find out what should be your ownership and permission, you can check the followings:

For mount options:
man ntfs-3g
man mount

For permissions:
http://ubuntuforums.org/showthread.php?t=1453342 -- Don't forget to read it to the end in the next page. The last answer is also good.
http://linuxzoo.net/page/sec_umask.html
http://permissions-calculator.org/info/
Last edited by taiyebur on 2015/11/13 07:16:49, edited 1 time in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Can't change partition permission/ownership with chmod,c

Post by gerald_clark » 2015/11/12 19:28:16

I suggest you read the manual.

man ntfs-3g

It explains user and group mapping and permissions.

taiyebur
Posts: 5
Joined: 2015/11/10 06:45:33

Re: [SOLVED]chmod/chown does not change permission/ownership

Post by taiyebur » 2015/11/13 07:19:32

I suggest you read the manual.

man ntfs-3g

It explains user and group mapping and permissions.
Thanks for pointing me there. It led me to more good stuff about mount and permissions. The solution is given in the original post under "SOLUTION".

Post Reply

Return to “CentOS 7 - General Support”