2

I was working on a project of mine and stumbled upon the USB mass storage mounting mechanism of ubuntu which confuses me quite a lot, let me explain.

I had never noticed that from a terminal in order to use the "mount" command you need to have root access i.e. "sudo mount". As I had only used it to mount drive partitions during an OS install it was fine.

On the other hand a USB thumb drive is automatically mounted (not the drive but rather the partitions) when connected to a computer (on the default Ubuntu install at least) without the current user having root access to the machine.

I first believed it was a matter of the automated process of mounting drives that had root access and allowed for the "mount" command but by going into the ubuntu "disks" utility one can easily unmount and mount again any partition of the USB thumb drive (by using the stop/play button) without being asked for any password granting root access. (I may have missed it)

It confuses me, How is the ubuntu disks utility able to mount the USB thumb drive partitions without having root access ?, Can I reproduce it from the terminal ?, If I can't, is there a native way in the classic ubuntu install to mount USB mass storage devices without requiring root access ?

I am already aware of some ways of mounting these USB partitions without root access by installing some additional packages, this is not what I'm interested in. I have seen https://help.ubuntu.com/community/Mount/USB where they talk about using "pmount" as well as USB Storage Device Automount where "usbmount" is discussed. As far as I can tell those packages are not installed on my system so this is not what is happening when the ubuntu disks utility is mounting the USB partitions.

I may be wrong about some things I said, I may have missed something obvious. Please help un-confuse me.

P.S: As an extra question, How can I partition those USB devices without root access ?

1 Answers1

1

You can use udisksctl, and I think this tool uses the same back-end as the automount feature.

Example:

udisksctl mount --block-device /dev/sde5

See man udisksctl to learn more about this tool.

If you are asked to enter password, you may want to see question Stop asking for authentication to mount USB stick.


P.S: It is better to convert the extra question to a separate AskUbuntu question.

sudodus
  • 47,684