简体   繁体   中英

chown command returning Operation not permitted

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM