Linux cp Permission denied on ntfs file system

bashlinuxntfspermissions

Could someone kindly explain why I get this Permission Denied error? I personally am user g and as ls shows I have read and write permission for both source and destination. My system is slackware 14, and the device being written to is my ereader, an ntfs-3g file system.

I have other ntfs file systems, thumb drives, external HDDs etc to which I can write to as user. There is no perceptible difference in the permissions setup for any of them. Being ntfs, all of them are owned by root of group root. It is only with this ereader that I have this problem (though I can write to it as root). So I believe the problem is specific to this device, but I have no clue what it might be.

~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb/database/media/  
cp: cannot create regular file '/500gb/database/media/Wyndham-TheMidwichCuckoos.txt': Permission denied  
~ $ ls -l /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt                         
-rw-r--r-- 1 g users 380183 Aug 10 11:04 /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt  
~ $ ls -l /500gb/database/  
total 32  
drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache/  
drwxr-xr-x 3 root root 8192 Aug  5 13:26 layout/  
drwxr-xr-x 2 root root 8192 Aug  9 14:07 media/  
drwxr-xr-x 2 root root 8192 Aug  5 17:28 sync/  
~ $

The ereader is fat32, I had assumed it to be ntfs,
~ $ mount
/dev/sda3 on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda4 on /home type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /winxp type fuseblk (rw,allow_other,blksize=4096,default_permissions)
/dev/sdb on /500gb type vfat (rw)
/dev/sdd1 on /3tb type fuseblk (rw,allow_other,blksize=4096)
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /3tb
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb
cp: cannot create regular file '/500gb/Wyndham-TheMidwichCuckoos.txt': Permission denied
~ $

I am not able to change the permissions on this ereader, neither as root, nor as user
As root, it appears to work, but nothing changes
/home/g # chmod 777 -R /500gb/database
/home/g # ls -l /500gb/database
total 32
drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache
drwxr-xr-x 3 root root 8192 Aug 5 13:26 layout
drwxr-xr-x 2 root root 8192 Aug 9 14:07 media
drwxr-xr-x 2 root root 8192 Aug 5 17:28 sync

As user, the chmod is rejected thus
~ $ chmod 777 -R /500gb/database
chmod: changing permissions of '/500gb/database': Operation not permitted
chmod: changing permissions of '/500gb/database/cache': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/cacheExt.xml': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/media.xml': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/cacheExtSchema_1.1.xsb': Operation not permitted
chmod: changing permissions of '/500gb/database/media': Operation not permitted
chmod: changing permissions of '/500gb/database/media/Stevenson-TreasureIsland.txt': Operation not permitted
chmod: changing permissions of '/500gb/database/media/Rendell-WolftotheSlaughter.txt': Operation not permitted

This process did the trick for me, thanks to Miroslav Koskar
/home/g # mount | grep sdb
/home/g # mount /dev/sdb -o uid=1000,gid=100 /500gb
/home/g # mount | grep sdb
/dev/sdb on /500gb type vfat (rw,uid=1000,gid=100)
/home/g # ls -l /500gb/database
total 32
drwxr-xr-x 2 g users 8192 Aug 10 11:23 cache
drwxr-xr-x 3 g users 8192 Aug 5 13:26 layout
drwxr-xr-x 2 g users 8192 Aug 10 12:51 media
drwxr-xr-x 2 g users 8192 Aug 5 17:28 sync
/home/g #
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb/database/media
~ $

Best Answer

It seems to me that permissions are not correctly set.

  1. you are user g and can read a file = OK

  2. but you can't create a file in a destination because the directory media is not writeable by you, only root can do that

So either copy as root or change the permissions on target so that you have a write permission on media directory.


As pointed out it's not possible to change permissions nor ownership on mounted NTFS filesystem. In that case there is a possibility to use proper mount options. Bellow excerpt from man mount

uid=value, gid=value and umask=value

Set the file permission on the filesystem. The umask value is given in octal. By default, the files are owned by root and not readable by somebody else.


Example: (for /dev/sdc1 with FAT32 filesystem)

Check that the device is not mounted (following should return without output)

$ mount | grep sdc1

Mount the device with uid and gid option set

$ sudo mount /dev/sdc1 -o uid=1000,gid=1000 /mnt

Verify the mountpoint

$ mount | grep sdc1

/dev/sdc1 on /mnt type vfat (rw,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
Related Question