Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have been wondering how this is possible (i.e. how this works internally). When you want to mount a directory you have to be root.

sudo mount /dev/something /mnt/somedir

I know you can get around that by adding a line in fstab.

Now, I'm wondering how come if I insert let's say an usb stick and select it from within Dolphin (KDE's filemanager), it mounts it without the need for a root password and gives me write/read access to what it has mounted? I'm guessing it is using dbus to monitor for new devices. I don't see how (when it knows there is something it should be mounted) it can mount it without the need for root. I haven't yet figured out how to manually mount some device without root and maybe I can learn something from how Dolphin does it.

share|improve this question
3  
Read Dbus and ConsoleKit. A similar question which might help you: unix.stackexchange.com/questions/45302/… –  darnir Jan 27 '13 at 10:11
    
Arch doesn't use ConsoleKit anymore but instead logind But the concepts mentioned on darnir's comment still apply. –  Martín Canaval Jan 28 '13 at 6:32
    
@darnir, what is the "dbus-send" command to mount? –  Nicolas Jan 28 '13 at 17:19

1 Answer 1

up vote 3 down vote accepted

This is done by udisks. There are two versions of udisks, "udisks" and "udisks2". You have probably installed at least one of them. Both ship with commandline utilities. Both should work when Dolphin works.

udisks mounts the filesystems into /media/<label>.

$ udisks --mount /dev/sdc1
Mounted /org/freedesktop/UDisks/devices/sdc1 at /media/<label>
$ udisks --unmount /dev/sdc1

The utility for udisks2 is called udisksctl. It uses /run/media/$USERNAME/<label>

$ udisksctl mount -b /dev/sdc1
Mounted /dev/sdc1 at /run/media/t-8ch/<label>.
$ udisksctl unmount -b /dev/sdc1
Unmounted /dev/sdc1.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.