chown command returning Operation not permitted

58,971

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.

Share:
58,971
l00kitsjake
Author by

l00kitsjake

Updated on August 07, 2020

Comments

  • l00kitsjake
    l00kitsjake almost 4 years

    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
    
    • mstrthealias
      mstrthealias almost 10 years
      Looks like /media/USBHDD1 is a NTFS or VFAT partition which has the user/group ownership configured at mount time.
    • wildplasser
      wildplasser almost 10 years
      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 ?
    • mstrthealias
      mstrthealias almost 10 years
      Include the output of grep USBHDD1 /etc/mtab in your question.
    • l00kitsjake
      l00kitsjake almost 10 years
      @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
    • wildplasser
      wildplasser almost 10 years
      VFAT ist is. @myninjaname was right. VFAT does not support ownership.
    • l00kitsjake
      l00kitsjake almost 10 years
      @wildplasser how can I change this to not be VFAT then? Is that a possible solution?
  • mstrthealias
    mstrthealias almost 10 years