19

I am working on a raspberry pi and am having a tough time giving permissions to an external hard drive that I have mounted using the following tutorial:

http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/

I have now created folders on that external hard drive and when I do a ls -l command I get the following returned:

drwxr-xr-x 2 root root 512 Aug 28 23:24 test

That is located in: /media/USBHDD1/shares

Now I'm trying to give it all write read and execute permissions or even change the owner and group to pi:pi

However, chmod 777 is not working – it doesn't return an error, just seems to have no effect

And when I use

sudo chown -R pi:pi test/

I get the error

chown: changing ownership of `test/': Operation not permitted

This is a linux question but I think someone with background and knowledge of using a raspberry pi can help me out here.

Extra info as requested:

When I run pi@raspberrypi /media $ grep USBHDD1 /etc/mtab it returns:

/dev/sda1 /media/USBHDD1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
daphtdazz
  • 7,754
  • 34
  • 54
l00kitsjake
  • 955
  • 3
  • 11
  • 24
  • 2
    Looks like `/media/USBHDD1` is a NTFS or VFAT partition which has the user/group ownership configured at mount time. – mstrthealias Aug 28 '14 at 23:56
  • Either that, or it is mounted read-only. To the OP: what is the mountpoint? ( `/media/USBHDD1/shares/` or `/media/USBHDD1/` ? ) and What is the `pwd` when issuing the chmod command ? – wildplasser Aug 28 '14 at 23:58
  • Include the output of `grep USBHDD1 /etc/mtab` in your question. – mstrthealias Aug 29 '14 at 00:01
  • @wildplasser I believe the mountpoint is /media/USBHDD1/shares and Im not prompted for a password when using chmod. Any command I use 'sudo' in, Im never prompted for a password – l00kitsjake Aug 29 '14 at 00:01
  • 3
    VFAT ist is. @myninjaname was right. VFAT does not support ownership. – wildplasser Aug 29 '14 at 00:04
  • @wildplasser how can I change this to not be VFAT then? Is that a possible solution? – l00kitsjake Aug 29 '14 at 00:15

1 Answers1

22

The reason is because the ownership and permissions are defined at mount time for the vfat FS.

Manual page mount(8):

Mount options for fat ..

   uid=value and gid=value

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

   umask=value

          Set the umask (the bitmask  of  the  permissions  that  are  not
          present).  The default is the umask of the current process.  The
          value is given in octal.

There are at least three things you can do:

(1) Give pi:pi access to the entire /media/USBHDD1 mount:

mount -o remount,gid=<pi's gid>,uid=<pi's uid> /media/USBHDD1

To determine pi's uid:

cat /etc/passwd |grep pi

To determine pi's gid:

cat /etc/group |grep pi

(2) Give everyone access to /media/USBHDD1 by changing the umask and dmask (not recommended):

mount -o remount,umask=000,dmask=000 /media/USBHDD1

(3) Change the partition to a different file system. Only do this if you're not accessing the the external hard drive from a windows computer:

You won't be able to convert the file system from VFAT to a Unix-compatible FS, so you'll have to backup the contents of the drive, format as EXT3+ or reiserfs, then copy the contents back. You can find tutorials for doing this on the web.

mstrthealias
  • 2,781
  • 2
  • 22
  • 18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60204/discussion-between-myninjaname-and-l00kitsjake). – mstrthealias Aug 29 '14 at 00:41
  • It may be a bit unsecure, but adding "umask=000,dmask=000" in the /etc/fstab file for the mounted drive that I serve with samba, solved the chown error. In my case the error was generated by the gitlab installer with docker-compose – marcor92 Sep 01 '23 at 17:55