如何以普通用户(非 root 用户)身份挂载分区?

如何以普通用户(非 root 用户)身份挂载分区?

我有一个双启动设置,其中有几个 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.

相关内容