使用Udisks2无需密码挂载分区

Hep*_*cal 7 linux fedora mount

我试图通过在 thunar 中单击它们或udisksctl mount -b /dev/sdb6 &在脚本中运行来在硬盘驱动器上安装一些分区,但我找不到一种方法来不出现密码提示。

我在团体中<myusername> wheel usersusers我一开始并不在该小组中,因此我将自己添加到其中以尝试完成这项工作。

我的 fstab 看起来像这样:

#
# /etc/fstab
# Created by anaconda on Sun Mar 12 19:43:55 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/luks-d7a09ab1-cfa0-4910-ad28-041248fd55ed /                       ext4    defaults,x-systemd.device-timeout=0 1 1
UUID=d713df23-90c8-4ed3-9246-9467be868d5d /boot                   ext2    defaults        1 2
/dev/sdb6   /run/media/username/shared/ vfat    noauto,user,exec,rw,async,atime 0 0
/dev/sdb12  /run/media/username/extra/      ext4 noauto,user,exec,rw,async,atime    0 0
Run Code Online (Sandbox Code Playgroud)

实际上,这样做的全部目的是在登录时安装这两个分区而不增加启动时间(它们是媒体分区),因此如果有一种方法可以在后台执行此操作,那就更好了。

小智 4

AFAIK udisks 需要一个策略包规则来允许未经身份验证的用户安装磁盘。正如本页所示,只需创建一个包含以下内容的文件/etc/polkit-1/rules.d/10-udisks2.rules

// See the polkit(8) man page for more information
// about configuring polkit.

// Allow udisks2 to mount devices without authentication
// for users in the "wheel" group.
polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
         action.id == "org.freedesktop.udisks2.filesystem-mount") &&
        subject.isInGroup("wheel")) {
        return polkit.Result.YES;
    }
});
Run Code Online (Sandbox Code Playgroud)