![如何以普通用户(非 root 用户)身份挂载分区?](https://linux22.com/image/923607/%E5%A6%82%E4%BD%95%E4%BB%A5%E6%99%AE%E9%80%9A%E7%94%A8%E6%88%B7%EF%BC%88%E9%9D%9E%20root%20%E7%94%A8%E6%88%B7%EF%BC%89%E8%BA%AB%E4%BB%BD%E6%8C%82%E8%BD%BD%E5%88%86%E5%8C%BA%EF%BC%9F.png)
我有一个双启动设置,其中有几个 NTFS 分区在 Ubuntu 和 Windows 之间共享。我希望这些分区在启动时自动挂载。但我希望它们以普通用户身份挂载,因为以 root 身份挂载有时会导致以下问题这对我来说。我尝试使用 进行安装,fstab
但它以 root 身份安装这些分区。而且该实用程序pmount
似乎仅适用于可移动驱动器。
是否有任何实用程序或脚本可以帮助我在系统启动时以普通用户身份(像文件管理器一样)挂载这些分区?
答案1
阅读man mount.ntfs
,它将告诉您如何以用户身份挂载分区(使用uid=
和gid
参数。从man mount.ntfs
页面:
Access Handling and Security
By default, files and directories are owned by the effective user and group of the mounting process, and everybody has
full read, write, execution and directory browsing permissions. You can also assign permissions to a single user by
using the uid and/or the gid options together with the umask, or fmask and dmask options.
Doing so, Windows users have full access to the files created by ntfs-3g.
But, by setting the permissions option, you can benefit from the full ownership and permissions features as defined by
POSIX. Moreover, by defining a Windows-to-Linux user mapping, the ownerships and permissions are even applied to Windows
users and conversely.
If ntfs-3g is set setuid-root then non-root users will be also able to mount volumes.
但是,root
仍然涉及到(因为“挂载”是系统级的事情),并且无法挂载的 NTFS 驱动器将导致它挂起,它们是自动挂载的,所以不要auto
在您的/etc/fstab
条目中使用。
阅读man mount
,特别是有关user
参数的内容:
The non-superuser mounts.
Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, any‐
body can mount the corresponding filesystem.