8

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.

Silverrocker
  • 1,835

1 Answers1

10

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.
t-8ch
  • 1,823