7

I'm trying to mount some partitions on my hard drive by clicking them in thunar or running udisksctl mount -b /dev/sdb6 & in a script, but I can't find a way for this not to come up with a password prompt.

I am in the groups <myusername> wheel users. I wasn't in the users group to start with, so i added myself to it in an attempt to make this work.

My fstab looks like this:

#
# /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

Really, the whole purpose of this is to mount these two partitions on login without increasing boot time (they are media partitions), so if there's a way to do that in the background then that would be even better.

4 Answers 4

4

AFAIK udisks needs a policykit rule to allow an unauthenticated user to mount disks. As this page suggests, just create a file /etc/polkit-1/rules.d/10-udisks2.rules containing:

// 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;
    }
});
1
  • That did the trick, thanks! To other searchers, a workaround with different problems is to have passwordless sudo enabled and run the command with sudo. Mar 26, 2017 at 19:57
3

Andrew M's answer does not work if you have a pkaction of version 0.105 or less.
To check pkaction version:

pkaction --version

pkaction version 0.105

If pkaction version is 0.105 or less, creating the rule /etc/polkit-1/rules.d/10-udisks2.rules will not work.
For pkaction version 0.105 or less (haven't tested with versions less than 0.105), create the file /etc/polkit-1/localauthority/50-local.d/50-udisks.pkla with the following content:

[udisks]
Identity=unix-group:sudo
Action=org.freedesktop.udisks2.filesystem-mount-system
ResultAny=yes
ResultInactive=no
ResultActive=yes
This allows anyone in the sudo group to mount partitions using udisks2 without authentication.

The difference between Forrest Voight's and this answer is that though both of them works, this method does not allow blanket password less authentication for all actions. The password less authentication is only enabled for mounting partitions.

1
  • 2
    Worked for me when changing the Action= line to Action=org.freedesktop.udisks2.filesystem-mount-other-seat . Thank you! Oct 4, 2021 at 12:53
1

I could apply permission to udisks with the following setting.

/etc/polkit-1/localauthority/50-local.d/50-udisks.pkla

[udisks]
Identity=unix-group:users
Action=org.freedesktop.udisks*
ResultAny=yes
ResultInactive=no
ResultActive=yes

Reference: https://mxlinux.org/wiki/system/mount-internal-partition-without-using-root-password/

0

Andrew M.'s answer works with newer versions of Ubuntu, but for Ubuntu 17.04 or lower, PolicyKit configuration works differently.

Creating /etc/polkit-1/localauthority/50-local.d/99-allow-sudo-group-to-do-anything-without-password.pkla with the following contents:

[AllowSudoGroupToDoAnythingWithoutPassword]
Identity=unix-group:sudo
Action=*
ResultAny=yes

allows users in the sudo group to have blanket passwordless authentication.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .