linux - chown 命令返回 Operation not permitted

标签 linux raspberry-pi usb-drive chown fat

<分区>

我正在使用 raspberry pi 工作,并且很难授予我使用以下教程安装的外部硬盘驱动器的权限:

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

我现在已经在该外部硬盘驱动器上创建了文件夹,当我执行 ls -l 命令时,我得到以下返回信息:

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

位于:/media/USBHDD1/shares

现在我试图给它所有的写读和执行权限,甚至将所有者和组更改为 pi:pi

但是,chmod 777 不工作——它没有返回错误,只是似乎没有效果

当我使用

sudo chown -R pi:pi test/

我得到了错误

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

这是一个 linux 问题,但我认为具有使用 raspberry pi 的背景和知识的人可以帮助我。

要求的额外信息:

当我运行 pi@raspberrypi/media $ grep USBHDD1/etc/mtab 它返回:

/dev/sda1 /media/USBHDD1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0

最佳答案

原因是因为所有权和权限是在挂载时为 vfat 定义的财政司司长。

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.

您至少可以做三件事:

(1) 给pi:pi访问整个/media/USBHDD1 安装:

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

确定 pi 的 uid:

cat /etc/passwd |grep pi

确定 pi 的 gid:

cat /etc/group |grep pi

(2) 让每个人都可以访问 /media/USBHDD1通过更改 umaskdmask (不推荐):

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

(3) 将分区更改为不同的文件系统。仅当您不是从 Windows 计算机访问外部硬盘驱动器时才执行此操作:

您无法将文件系统从 VFAT 转换为 Unix 兼容的 FS,因此您必须备份驱动器的内容,格式化为 EXT3+ 或 reiserfs,然后将内容复制回来。 您可以在网上找到执行此操作的教程。

关于linux - chown 命令返回 Operation not permitted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25559700/

相关文章:

qt - 使用 OMXPLAYER 在 QT 上播放视频

linux - 如何使用 spi-loopback-test linux 内核模块?

linux - FAT : Directory bread error causes a kernel crash and reboot system

assembly - 如何在 BIOS 下使用 U 盘执行低级 IO(相对于软盘)?

linux - 如何通过 Mellanox 的 ConnectX-5 设备的 PCI 设备获取 HCA 的以太网接口(interface)名称

linux - 将 Lazarus 应用程序从 Windows 移植到 Linux

python - 对于运行 Web 应用程序的 Raspberry Pi,我应该使用哪个 Python 版本?

C++,Windows 7 : recognize usb thumbdrive was connected and recognize usb identifier?

Java - 我怎样才能让我的应用程序长期稳定运行,这样它就不会打嗝,卡住?

python - bash 命令通过 cli 正常运行但不在 python 脚本中运行