LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2018, 11:07 AM   #1
linuxbawks
Member
 
Registered: Apr 2013
Distribution: Snuckware
Posts: 240

Rep: Reputation: 17
Mounting a USB drive using udisks


I've been mounting removable drives by giving a usergroup sudo privileges to /bin/mount and /bin/umount.

I now want to use udisks. I have Dbus installed and I also have p11-kit installed through dependency resolution for some other apps. I have now installed policykit.

In /etc/polkit-1/rules.d, there is this file:

20-plugdev-group-mount-override.rules
Code:
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.udisks2.filesystem-mount" &&
        subject.isInGroup("plugdev")) {
        return polkit.Result.YES;
    }
});

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.udisks2.eject-media" &&
        subject.isInGroup("plugdev")) {
        return polkit.Result.YES;
    }
});
Now the user is part of %plugdev but I'm still only able to mount a drive using sudo:

Code:
sudo udisksctl mount -b /dev/sd**
It's my understanding that I should be able to mount without sudo as the user is in the correct group and polkit should return YES.

Code:
$ udisksctl mount -b /dev/sd**
Error mounting /dev/sdd1: GDBus.Error:org.freedesktop.UDisks2.Error.NotAuthorized: Not authorized to perform operation (polkit authority not available and caller is not uid 0)

Last edited by linuxbawks; 01-21-2018 at 11:10 AM.
 
Old 01-21-2018, 01:04 PM   #2
linuxbawks
Member
 
Registered: Apr 2013
Distribution: Snuckware
Posts: 240

Original Poster
Rep: Reputation: 17
pkaction or pkexec gives me:

Code:
Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 127
 
Old 01-22-2018, 12:06 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
I have used this for years, as is. no sudo or polkit anything.
Just edit for your device and mount point and run by the user(s). (one script per user)
Tip: Mount under /media/<user>/mount_point or else.
mount_point need not exist prior to the mount.

Code:
#!/bin/bash
cd $HOME ; sync
/usr/bin/udisksctl mount -b /dev/sdc1 /media/jj/external  > /dev/null 2>&1
/usr/bin/ionice -c 3 /usr/bin/rsync -avz  . /media/jj/external/LM17/ --delete # --exclude Videos
#EOF
Everything is user:user and
DIRs are 755
files = 644

Good luck.

Last edited by Habitual; 01-22-2018 at 12:09 PM.
 
Old 01-22-2018, 01:16 PM   #4
m.a.l.'s pa
Member
 
Registered: Oct 2007
Location: albuquerque
Distribution: Debian, Arch, Kubuntu
Posts: 310

Rep: Reputation: 111Reputation: 111
Yes, I think you should be able to mount them without sudo; I've been doing it this way for a long time now, on various systems -- Debian, Arch, whatever. I thought it worked the same for everone. I don't have to do anything to set it up and I don't even understand the details. I don't use a script or anything, I simply pull the commands from bash history.

Check with lsblk to make sure the flash drive is detected:

Code:
$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
[...]
sdb      8:16   1  14.9G  0 disk 
└─sdb1   8:17   1  14.9G  0 part
Mount:

Code:
$ udisksctl mount -b /dev/sdb1
Mounted /dev/sdb1 at /run/media/steve/5166-59C0.
 
Old 01-22-2018, 01:28 PM   #5
linuxbawks
Member
 
Registered: Apr 2013
Distribution: Snuckware
Posts: 240

Original Poster
Rep: Reputation: 17
Thanks for replying.

In order to run this command you still need sudo or polkit:

Code:
$ udisksctl mount -b /dev/sdb1
If I do this (without sudo) I still get:

Code:
Error mounting /dev/sdd1: GDBus.Error:org.freedesktop.UDisks2.Error.NotAuthorized: Not authorized to perform operation (polkit authority not available and caller is not uid 0)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fedora 7: autofs is not mounting USB flash drive or DVD ROM drive Hewson Linux - General 3 05-12-2008 09:58 AM
Mounting USB external drive with multiple partitions, USB bluetooth mouse xmeson Slackware 7 12-17-2006 10:00 AM
Mounting split raid drive as normal drive via USB William_Syd Linux - Newbie 2 11-01-2006 08:07 PM
USB drive mounting RohanShrivastav SUSE / openSUSE 10 06-08-2005 03:57 AM
Mounting my USB external drive, USB 1.1 Devillion Linux - Hardware 4 01-04-2004 10:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration